Bikesh Srivastava

Bikesh Srivastava

  • 80
  • 23.8k
  • 3.5m

Web connector Error with QuickBook in ASMX service

Aug 3 2016 8:12 AM

Hi Friends ,

I am facing error "Error QBWC1042: ReceiveResponseXML failed – Error message: The operation has timed out",

Once i tried to run web service(ASMX service) with web connector for Quickbook throwing that error.

According my requirment i am posting Invoice of some client in Quickbook ,

No of Client :-300 and each client have 100+ invoice .

=>I've created request for each client and invoices in service and response

Request code:-

  1. [WebMethod(Description = "This web method facilitates web service to send request XML to QuickBooks via QBWebConnector", EnableSession = true)]  
  2.   
  3. public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,  
  4.             string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers)  
  5.         {  
  6.   
  7.   
  8.             if (Session["counter"] == null)  
  9.             {  
  10.                 Session["counter"] = 0;  
  11.             }  
  12.             string evLogTxt = "WebMethod: sendRequestXML() has been called by QBWebconnector" + "\r\n\r\n";  
  13.             evLogTxt = evLogTxt + "Parameters received:\r\n";  
  14.             evLogTxt = evLogTxt + "string ticket = " + ticket + "\r\n";  
  15.             evLogTxt = evLogTxt + "string strHCPResponse = " + strHCPResponse + "\r\n";  
  16.             evLogTxt = evLogTxt + "string strCompanyFileName = " + strCompanyFileName + "\r\n";  
  17.             evLogTxt = evLogTxt + "string qbXMLCountry = " + qbXMLCountry + "\r\n";  
  18.             evLogTxt = evLogTxt + "int qbXMLMajorVers = " + qbXMLMajorVers.ToString() + "\r\n";  
  19.             evLogTxt = evLogTxt + "int qbXMLMinorVers = " + qbXMLMinorVers.ToString() + "\r\n";  
  20.             evLogTxt = evLogTxt + "\r\n";  
  21.   
  22.             ArrayList req = buildRequest();  
  23.   
  24.   
  25.   
  26.             string request = "";  
  27.             int total = req.Count;  
  28.             count = Convert.ToInt32(Session["counter"]);  
  29.   
  30.             if (count < total)  
  31.             {  
  32.                 request = req[count].ToString();  
  33.                 evLogTxt = evLogTxt + "sending request no = " + (count + 1) + "\r\n";  
  34.                 Session["counter"] = ((int)Session["counter"]) + 1;  
  35.             }  
  36.             else  
  37.             {  
  38.                 count = 0;  
  39.                 Session["counter"] = 0;  
  40.                 request = "";  
  41.             }  
  42.             evLogTxt = evLogTxt + "\r\n";  
  43.             evLogTxt = evLogTxt + "Return values: " + "\r\n";  
  44.             evLogTxt = evLogTxt + "string request = " + request + "\r\n";  
  45.             logEvent(evLogTxt);  
  46.   
  47.   
  48.             return request;  
  49.   
  50.         }  
Get response code:-
  1. [WebMethod(Description = "This web method facilitates web service to receive response XML from QuickBooks via QBWebConnector", EnableSession = true)]  
  2.   
  3.  public int receiveResponseXML(string ticket, string response, string hresult, string message)  
  4.         {  
  5.   
  6.            
  7.             var reader = XmlReader.Create(new StringReader(response));  
  8.             var xml_Doc = XDocument.Load(reader);  
  9.   
  10.             //var nodes = from n in xml_Doc.Descendants("DataExtRet")  
  11.             //             .Where(x => x.Element("DataExtName").Value.Contains("CRXIS Client Id"))  
  12.             //            select n.Element("DataExtValue").Value;  
  13.   
  14.             var nodes = (from n in xml_Doc.Descendants("CustomerRet")  
  15.                         select new QBClient  
  16.                          {  
  17.                              ClientListId = n.Element("ListID").Value,  
  18.                              ClientId = (from nx in n.Descendants("DataExtRet")  
  19.                                             .Where(x => x.Element("DataExtName").Value.Contains("CRXIS Client Id"))  
  20.                                          select nx.Element("DataExtValue").Value).FirstOrDefault()  
  21.                          }).ToList() ;  
  22.   
  23.   
  24.   
  25.   
  26.                var r=objinvoice.InsertQBClient(nodes);  
  27.   
  28.            
  29.             
  30.                 var invoiceNumber = (from n in xml_Doc.Descendants("InvoiceRet")  
  31.                                     select n.Element("RefNumber").Value).FirstOrDefault() ;  
  32.   
  33.                 if (invoiceNumber!=null)  
  34.                 {  
  35.                     var result = objinvoice.UpdateQBflag(invoiceNumber.ToString());   
  36.                 }  
  37.   
  38.                
  39.              
  40.   
  41.             string evLogTxt = "WebMethod: receiveResponseXML() has been called by QBWebconnector" + "\r\n\r\n";  
  42.             evLogTxt = evLogTxt + "Parameters received:\r\n";  
  43.             evLogTxt = evLogTxt + "string ticket = " + ticket + "\r\n";  
  44.             evLogTxt = evLogTxt + "string response = " + response + "\r\n";  
  45.             evLogTxt = evLogTxt + "string hresult = " + hresult + "\r\n";  
  46.             evLogTxt = evLogTxt + "string message = " + message + "\r\n";  
  47.             evLogTxt = evLogTxt + "\r\n";  
  48.   
  49.             int retVal = 0;  
  50.             if (!hresult.ToString().Equals(""))  
  51.             {  
  52.                 // if there is an error with response received, web service could also return a -ve int       
  53.                 evLogTxt = evLogTxt + "HRESULT = " + hresult + "\r\n";  
  54.                 evLogTxt = evLogTxt + "Message = " + message + "\r\n";  
  55.                 retVal = -101;  
  56.             }  
  57.             else  
  58.             {  
  59.                 evLogTxt = evLogTxt + "Length of response received = " + response.Length + "\r\n";  
  60.   
  61.                 ArrayList req = buildRequest();  
  62.                 int total = req.Count;  
  63.                 int count = Convert.ToInt32(Session["counter"]);  
  64.   
  65.                 int percentage = (count * 100) / total;  
  66.                 if (percentage >= 100)  
  67.                 {  
  68.                     count = 0;  
  69.                     Session["counter"] = 0;  
  70.                 }  
  71.                 retVal = percentage;  
  72.             }  
  73.             evLogTxt = evLogTxt + "\r\n";  
  74.             evLogTxt = evLogTxt + "Return values: " + "\r\n";  
  75.             evLogTxt = evLogTxt + "int retVal= " + retVal.ToString() + "\r\n";  
  76.             logEvent(evLogTxt);  
  77.   
  78.             return retVal;  
  79.         }  
Please resolve this issue.

Answers (1)