none
Web connector Error with QuickBook in ASMX service. RRS feed

  • Question

  • 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:-                                              

    [WebMethod(Description = "This web method facilitates web service to send request XML to QuickBooks via QBWebConnector", EnableSession = true)]
    
    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;
    
            }
    

    Get response code:- 

    [WebMethod(Description = "This web method facilitates web service to receive response XML from QuickBooks via QBWebConnector", EnableSession = true)]
    
     public int receiveResponseXML(string ticket, string response, string hresult, string message)
            {
    
             
                var reader = XmlReader.Create(new StringReader(response));
                var xml_Doc = XDocument.Load(reader);
    
                //var nodes = from n in xml_Doc.Descendants("DataExtRet")
                //             .Where(x => x.Element("DataExtName").Value.Contains("CRXIS Client Id"))
                //            select n.Element("DataExtValue").Value;
    
                var nodes = (from n in xml_Doc.Descendants("CustomerRet")
                            select new QBClient
                             {
                                 ClientListId = n.Element("ListID").Value,
                                 ClientId = (from nx in n.Descendants("DataExtRet")
                                                .Where(x => x.Element("DataExtName").Value.Contains("CRXIS Client Id"))
                                             select nx.Element("DataExtValue").Value).FirstOrDefault()
                             }).ToList() ;
    
    
    
    
                   var r=objinvoice.InsertQBClient(nodes);
    
             
              
                    var invoiceNumber = (from n in xml_Doc.Descendants("InvoiceRet")
                                        select n.Element("RefNumber").Value).FirstOrDefault() ;
    
                    if (invoiceNumber!=null)
                    {
                        var result = objinvoice.UpdateQBflag(invoiceNumber.ToString()); 
                    }
    
                 
               
    
                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;
            }
    
    

    Please resolve this issue .


    Wednesday, August 3, 2016 12:09 PM

Answers

  • You're getting a timeout error which means it is taking too long to process the request. Quickbooks is a third party product so we cannot provide any assistance for it. But in general timeout problems can be resolved by reducing the amount of work being sent to the service. It appears the timeout is occurring in your call to either InsertQBClient or UpdateQBFlag. Without any additional knowledge of QB it is hard to say. If the timeout is occurring while talking with QB then you'll need to adjust those calls. If the timeout is occurring on the client that is calling your web method then you'll need to modify your web method to make the calls async or perhaps break them up so the caller of your method doesn't time out.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, August 3, 2016 2:06 PM
    Moderator