I am trying to get all customers from QuickBooks 2013 Premier Edition using QBWebConnector. My request QBXML is as follows
string strRequestXML = "";
XmlDocument inputXMLDoc = null;
inputXMLDoc = new XmlDocument();
inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"4.0\""));
XmlElement qbXML = inputXMLDoc.CreateElement("QBXML");
inputXMLDoc.AppendChild(qbXML);
XmlElement qbXMLMsgsRq = inputXMLDoc.CreateElement("QBXMLMsgsRq");
qbXML.AppendChild(qbXMLMsgsRq);
qbXMLMsgsRq.SetAttribute("onError", "stopOnError");
XmlElement customerQueryRq = inputXMLDoc.CreateElement("CustomerQueryRq");
qbXMLMsgsRq.AppendChild(customerQueryRq);
customerQueryRq.SetAttribute("requestID", "whatever");
strRequestXML = inputXMLDoc.OuterXml;
req.Add(strRequestXML);
Above is my buildRequest Method from WebService , However I am not getting any errors , status is QBWebConnector is OK but doesnot see the response . Here is the log
20160117.21:51:42 UTC : QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'HTTPWebService' has STARTED
20160117.21:51:42 UTC : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20160117.21:51:42 UTC : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20160117.21:51:42 UTC : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: HTTPWebService
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): HTTPWebService
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: http://localhost/WCWebService/WCWebService.asmx
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="2.0.0.1">
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.2.0.34">
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'HTTPWebService', username = 'username'
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="username"><password=<MaskedForSecurity>
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.updateWS() : Received from authenticate() following parameters:<authRet[0]="e8c16e62-7395-469b-9e8d-ed491b2a578c"><authRet[1]="C:\Users\Public\Documents\Intuit\QuickBooks\Sample Company Files\QuickBooks 2015\Sample_Premier_ProductBased.QBW"><authRet[2]=""><authRet[3]="">
20160117.21:51:42 UTC : QBWebConnector.RegistryManager.setCurrentWebServiceName() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceName has been set to HTTPWebService
20160117.21:51:42 UTC : QBWebConnector.RegistryManager.setCurrentWebServiceSessionTicket() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceSessionTicket has been set to e8c16e62-7395-469b-9e8d-ed491b2a578c
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.CheckCFNResponse() : User authenticated.
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.do_authenticate() : Done.
20160117.21:51:42 UTC : QBWebConnector.SOAPWebService.OpenConnection() : Connecting to QuickBooks...
20160117.21:51:43 UTC : QBWebConnector.SOAPWebService.OpenConnection() : Connected., Session started
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="s......
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CompanyQueryRs requestID="1" ......
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.getLock() : Got Lock = UNLOCKED:GHAZANFAR
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.IsLocked() : Lock = UNLOCKED. Returning false.
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.Send_DataExtModRqXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="s......
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.Send_DataExtModRqXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<DataExtModRs requestID="1" st......
20160117.21:51:43 UTC : QBWebConnector.CompanyFileLock.setLock() : Lock has been set to value = <LOCKED:GHAZANFAR:635886643033561787> in QuickBooks for ownerID = <{87EDAAF8-637E-4203-867F-4BA79C2F8998}>
20160117.21:51:44 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="s......
20160117.21:51:44 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CompanyQueryRs requestID="1" ......
20160117.21:51:44 UTC : QBWebConnector.CompanyFileLock.getLock() : Got Lock = LOCKED:GHAZANFAR:635886643033561787
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.update() : Company file has been locked for update.
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.update() : Synchronizing with QuickBooks Company Name = Roving Auto Parts Pro
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Asking application to send request no. 1
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : *** Calling sendRequestXML() with following parameters:
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : wcTicket="e8c16e62-7395-469b-9e8d-ed491b2a578c"
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : HCPResponseXML=
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<HostQueryRs requestID="0" sta......
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : cfn="C:\Users\Public\Documents\Intuit\QuickBooks\Sample Company Files\QuickBooks 2015\Sample_Premier_ProductBased.QBW"
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbNationality="US"
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbXMLMajorVers="13"
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbXMLMinorVers="0"
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Received from sendRequestXML() following parameter:
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : strRequestXML =
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="4.0"?><QBXML><QBXMLMsgsRq onError="st......
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Request xml received.
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Processing request #1
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : REQUEST: received from application: size (bytes) = 148
20160117.21:51:44 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending request to QuickBooks.
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Response received from QuickBooks: size (bytes) = 107502
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending response back to application.
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : *** Calling receiveResponseXML() with following parameters:
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : wcTicket="e8c16e62-7395-469b-9e8d-ed491b2a578c"
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : response =
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="wh......
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : hresult=""
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : message=""
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : Received from receiveResponseXML() following parameters:
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : more="100">
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : Done. No more to process.
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="s......
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.Send_CompanyQueryRqXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CompanyQueryRs requestID="1" ......
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.getLock() : Got Lock = LOCKED:GHAZANFAR:635886643033561787
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.Send_DataExtModRqXML() : XML dump follows: -
<?xml version="1.0"?><?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="s......
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.Send_DataExtModRqXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<DataExtModRs requestID="1" st......
20160117.21:51:45 UTC : QBWebConnector.CompanyFileLock.unsetLock() : Company file has been unlocked for ownerID = <{87EDAAF8-637E-4203-867F-4BA79C2F8998}>
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.update() : Company file has been unlocked.
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.update() : Ending session to QuickBooks.
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.DisconnectFromQB() : Session ended and connection closed
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_closeConnection() : *** Calling closeConnection() with following parameter:<wcTicket="e8c16e62-7395-469b-9e8d-ed491b2a578c">
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_closeConnection() : Received from closeConnection() following parameter:<ccResponse="OK">
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_closeConnection() : CloseConnection called to application.
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_closeConnection() : Response received from application = OK
20160117.21:51:45 UTC : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20160117.21:51:45 UTC : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.update() : update completed.
20160117.21:51:45 UTC : QBWebConnector.WebServiceManager.DoUpdateSelected() : Update for application = 'HTTPWebService' has COMPLETED
20160117.21:51:45 UTC : QBWebConnector.WebServiceManager.DoUpdateSelected() : Update session has ended.
Edit Posting code :
public ArrayList buildRequest()
{
//Get All Customer Query
string strRequestXML = "";
XmlDocument inputXMLDoc = null;
inputXMLDoc = new XmlDocument();
inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"4.0\""));
XmlElement qbXML = inputXMLDoc.CreateElement("QBXML");
inputXMLDoc.AppendChild(qbXML);
XmlElement qbXMLMsgsRq = inputXMLDoc.CreateElement("QBXMLMsgsRq");
qbXML.AppendChild(qbXMLMsgsRq);
qbXMLMsgsRq.SetAttribute("onError", "stopOnError");
XmlElement customerQueryRq = inputXMLDoc.CreateElement("CustomerQueryRq");
qbXMLMsgsRq.AppendChild(customerQueryRq);
customerQueryRq.SetAttribute("requestID", "whatever");
strRequestXML = inputXMLDoc.OuterXml;
req.Add(strRequestXML);
// Clean up
strRequestXML="";
inputXMLDoc=null;
qbXML=null;
qbXMLMsgsRq=null;
//maxReturned=null;
return req;
}
public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers)
{
if (Session["counter"] == null) {
Session["counter"] = 0;
}
string evLogTxt="WebMethod: sendRequestXML() has been called by QBWebconnector" + "\r\n\r\n";
evLogTxt=evLogTxt+"Parameters received:\r\n";
evLogTxt=evLogTxt+"string ticket = " + ticket + "\r\n";
evLogTxt=evLogTxt+"string strHCPResponse = " + strHCPResponse + "\r\n";
evLogTxt=evLogTxt+"string strCompanyFileName = " + strCompanyFileName + "\r\n";
evLogTxt=evLogTxt+"string qbXMLCountry = " + qbXMLCountry + "\r\n";
evLogTxt=evLogTxt+"int qbXMLMajorVers = " + qbXMLMajorVers.ToString() + "\r\n";
evLogTxt=evLogTxt+"int qbXMLMinorVers = " + qbXMLMinorVers.ToString() + "\r\n";
evLogTxt=evLogTxt+"\r\n";
ArrayList req=buildRequest();
string request="";
int total = req.Count;
count=Convert.ToInt32(Session["counter"]);
if(count<total) {
request=req[count].ToString();
evLogTxt=evLogTxt+ "sending request no = " + (count+1) + "\r\n";
Session["counter"] = ((int) Session["counter"]) + 1;
}
else{
count=0;
Session["counter"]=0;
request="";
}
evLogTxt=evLogTxt+"\r\n";
evLogTxt=evLogTxt+"Return values: " + "\r\n";
evLogTxt=evLogTxt+"string request = " + request + "\r\n";
logEvent(evLogTxt);
return request;
}
[ WebMethod(Description="This web method facilitates web service to receive response XML from QuickBooks via QBWebConnector",EnableSession=true) ]
/// <summary>
/// WebMethod - receiveResponseXML()
/// Signature: public int receiveResponseXML(string ticket, string response, string hresult, string message)
///
/// IN:
/// string ticket
/// string response
/// string hresult
/// string message
///
/// OUT:
/// int retVal
/// Greater than zero = There are more request to send
/// 100 = Done. no more request to send
/// Less than zero = Custom Error codes
/// </summary>
public int receiveResponseXML(string ticket, string response, string hresult, string message)
{
string evLogTxt="WebMethod: receiveResponseXML() has been called by QBWebconnector" + "\r\n\r\n";
evLogTxt=evLogTxt+"Parameters received:\r\n";
evLogTxt=evLogTxt+"string ticket = " + ticket + "\r\n";
evLogTxt=evLogTxt+"string response = " + response + "\r\n";
evLogTxt=evLogTxt+"string hresult = " + hresult + "\r\n";
evLogTxt=evLogTxt+"string message = " + message + "\r\n";
evLogTxt=evLogTxt+"\r\n";
int retVal=0;
if(!hresult.ToString().Equals("")){
// if there is an error with response received, web service could also return a -ve int
evLogTxt=evLogTxt+ "HRESULT = " + hresult + "\r\n";
evLogTxt=evLogTxt+ "Message = " + message + "\r\n";
retVal=-101;
}
else{
evLogTxt=evLogTxt+ "Length of response received = " + response.Length + "\r\n";
ArrayList req = buildRequest();
int total=req.Count;
int count=Convert.ToInt32(Session["counter"]);
int percentage=(count*100)/total;
if (percentage>=100){
count=0;
Session["counter"]=0;
}
retVal=percentage;
}
evLogTxt=evLogTxt+"\r\n";
evLogTxt=evLogTxt+"Return values: " + "\r\n";
evLogTxt=evLogTxt+"int retVal= " + retVal.ToString() + "\r\n";
logEvent(evLogTxt);
return retVal;
}
Here is my send and response methods . Problem is that how do I see the response of getting all customers , and How do I test response in browser ? If I want to test the the service in browser how do I do that ? I want to parse the response in C# classes and use it in my other app.
答案 0 :(得分:1)
正在使用receiveResponseXML(...)
方法成功向您发送回复。您可以在日志中看到这一点:
0160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : *** Calling receiveResponseXML() with following parameters:
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : wcTicket="e8c16e62-7395-469b-9e8d-ed491b2a578c"
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : response =
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="wh......
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : hresult=""
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : message=""
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : Received from receiveResponseXML() following parameters:
20160117.21:51:45 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : more="100">
您忽略了发布任何相关代码,因此除此之外帮助您将非常困难。
您应该查看Web连接器的工作原理。 QuickBooks SDK中提供了几百页的文档:
以下是另一个摘要:
关于您添加的问题:
问题是我如何看待获得所有客户的响应
您可以在日志中查看它,也可以将应用程序保存到数据库中,然后从那里显示给您。
如何在浏览器中测试响应?
您无法在浏览器中测试它。它是一个SOAP服务,它与您的Web浏览器无关,无论如何都是如此。
您永远不会仅使用Web连接器在浏览器中看到XML响应或其中的任何数据。
您需要解析XML,将其存储/缓存在您自己的数据库中,然后您可以根据需要在自己的应用程序中显示缓存/存储的数据。
您无法直接在浏览器中显示来自Web连接器的响应 - 您需要将其存储在某处/某种方式,然后显示存储的数据。