This repository was archived by the owner on Jul 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQBWebConnectorSvcSkeleton.java
More file actions
187 lines (150 loc) · 6.17 KB
/
Copy pathQBWebConnectorSvcSkeleton.java
File metadata and controls
187 lines (150 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**
* QBWebConnectorSvcSkeleton.java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: 1.6.2 Built on : Apr 17, 2012 (05:33:49 IST)
*/
package com.test.ws;
import com.intuit.developer.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Random;
import java.util.UUID;
/**
* QBWebConnectorSvcSkeleton java skeleton for the axisService
*/
public class QBWebConnectorSvcSkeleton {
static boolean stop = false;
private final Logger log = LoggerFactory.getLogger(QBWebConnectorSvcSkeleton.class);
private String authenticatedUserID;
/**
* Prepares and send QBXML request for execute on Quickbooks Company data.
*
* @param sendRequestXML
* @return sendRequestXMLResponse
*/
public SendRequestXMLResponse sendRequestXML(SendRequestXML sendRequestXML) {
log.info("sendRequestXML: " + sendRequestXML.toString());
SendRequestXMLResponse sendRequestXMLResponse = new SendRequestXMLResponse();
if (!stop) {
java.net.URL url = QBWebConnectorSvcSkeleton.class.getResource("request.xml");
try {
String xml = new java.util.Scanner(new File(url.getFile()), "UTF8").useDelimiter("\\Z").next();
xml = xml.replace("{{VendorName}}", "Vendor_" + new Random().nextLong());
sendRequestXMLResponse.setSendRequestXMLResult(xml);
stop = true;
} catch (FileNotFoundException e) {
log.error(e.getMessage(), e);
}
} else {
sendRequestXMLResponse.setSendRequestXMLResult("");
}
return sendRequestXMLResponse;
}
/**
* Received when there are error while connection to Quickbooks.
*
* @param connectionError
* @return connectionErrorResponse
*/
public ConnectionErrorResponse connectionError(ConnectionError connectionError) {
log.info("Connection error: " + connectionError.toString());
ConnectionErrorResponse connectionErrorResponse = new ConnectionErrorResponse();
connectionErrorResponse.setConnectionErrorResult("");
return connectionErrorResponse;
}
/**
* Notify Webconnector about server (this webservice) version.
*
* @param serverVersion
* @return serverVersionResponse
*/
public ServerVersionResponse serverVersion(ServerVersion serverVersion) {
log.info("serverVersion: " + serverVersion.toString());
ServerVersionResponse serverVersionResponse = new ServerVersionResponse();
serverVersionResponse.setServerVersionResult("1.0");
return serverVersionResponse;
}
/**
* Provides information about version of WebConnector.
* Allow to request user to update WebConnector if current version of WebConnector does not meet our requirements.
*
* @param clientVersion
* @return clientVersionResponse
*/
public ClientVersionResponse clientVersion(ClientVersion clientVersion) {
log.info("clientVersion: " + clientVersion.toString());
// create empty response for continue.
ClientVersionResponse clientVersionResponse = new ClientVersionResponse();
return clientVersionResponse;
}
/**
* Action on close connection with Quickbooks.
*
* @param closeConnection
* @return closeConnectionResponse
*/
public CloseConnectionResponse closeConnection(CloseConnection closeConnection) {
log.info("closeConnection: " + closeConnection.toString());
CloseConnectionResponse closeConnectionResponse = new CloseConnectionResponse();
closeConnectionResponse.setCloseConnectionResult("Close connection.");
return closeConnectionResponse;
}
/**
* Return errors.
*
* @param getLastError
* @return getLastErrorResponse
*/
public GetLastErrorResponse getLastError(GetLastError getLastError) {
log.info("getLastError: " + getLastError.toString());
GetLastErrorResponse lastErrorResponse = new GetLastErrorResponse();
// return empty: no errors.
return lastErrorResponse;
}
/**
* Authenticate user in our webservice.
*
* @param authenticate
* @return authenticateResponse
*/
public AuthenticateResponse authenticate(Authenticate authenticate) {
log.info("Authenticate:" + authenticate.toString());
// prepare response
AuthenticateResponse authenticateResponse = new AuthenticateResponse();
ArrayOfString arrayOfString = new ArrayOfString();
if ("user".equals(authenticate.getStrUserName()) && "123".equals(authenticate.getStrPassword())) {
// do authenticate
//The first member of the array is a session token, which could be a GUID or anything else that you want
// to use to identify the session. This token will be returned by QBWC in subsequent callbacks in the
// session
authenticatedUserID = UUID.randomUUID().toString();
arrayOfString.addString(authenticatedUserID);
stop = false;
// If you do have work to do for the that user, you can supply the full pathname of the company to be
// used in the current update
// e.g: arrayOfString.addString("c:\\Users\\Public\\Documents\\Test Company.qbw");
// empty for use opened company in Quickbooks.
arrayOfString.addString("");
} else {
// If the username and password in the authenticate call is invalid, you would supply the value “nvu”.
arrayOfString.addString("");
arrayOfString.addString("nvu");
stop = true;
}
authenticateResponse.setAuthenticateResult(arrayOfString);
return authenticateResponse;
}
/**
* Auto generated method signature
*
* @param receiveResponseXML
* @return receiveResponseXMLResponse
*/
public ReceiveResponseXMLResponse receiveResponseXML(ReceiveResponseXML receiveResponseXML) {
log.info("receiveResponseXML: " + receiveResponseXML.toString());
return new ReceiveResponseXMLResponse();
}
}