如何生成qwc文件以及如何通过Web连接器将数据与Quickbooks同步?

时间:2018-04-05 11:25:24

标签: c# quickbooks

我有Quickbooks Desktop Enterprise Solution 18.0试用版R5P和QB网络连接器2.2.0.80。

我是Quickbooks的新手。我已经浏览了这个链接(How to create a .qwc file for QuickBooks Web Connector?)。我生成了.qwc文件并尝试通过Web连接器连接quickbooks,我收到了一个错误 QWC1501: The new application was not added

这是我的qwc文件内容:

如果有任何错误,请指导我。

<?xml version="1.0"?>
<QBXML>
<AppName>WCWebService</AppName>
<AppID>
</AppID>
<AppURL>http://loaclhost/QBWebService.asmx</AppURL>
<AppDescription>A Short Description for WCWebservice</AppDescription>
<AppSupport>http://localhost/QBWebService.asmx?wsdl</AppSupport>
<UserName>Nagarajan</UserName>
<OwnerID>7ff3fabf-1c2c-490b-bff1-91148fc8d9a8</OwnerID>
<FileID>81d4dad8-a5dc-4b79-8c09-be679c9d8e28</FileID>
<QBType>QBFS</QBType>
<Scheduler>
<RunEveryNMinutes>2</RunEveryNMinutes>
</Scheduler>
</QBXML>`

日志文件说

Log file initialized at Sunday, April 8, 2018 - 10:10 AM UTC  
Timestamp format used: YYYYMMDD.HH:MM:SS UTC
QBWebConnector 2.2 has been initialized with its logging status to level = 
DEBUG.
Please restart QBWebConnector for any change in log level to take effect. 
Use file menu to clear log.

20180408.10:10:43 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : 
HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to 
False
20180408.10:10:43 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : 
********************* Update session unlocked *********************
20180408.10:10:43 UTC   : QWCReader.ParseQWC() : Contents of QWC file: -
<QBXML>
<AppName>WCWebService</AppName>
<AppID></AppID>
<AppURL>http://localhost/WCWebService.asmx</AppURL>
<AppDescription>A Short Description for WCWebservice</AppDescription>
<AppSupport>http://localhost/QBWebService.asmx?wsdl</AppSupport>
<UserName>Nagarajan</UserName>
<OwnerID>47c49092-071c-4edb-97a3-2715ab6325f8</OwnerID>
<FileID>1938435f-db77-40d2-8392-64ab98f5081c</FileID>
</QBXML>
20180408.10:10:45 UTC   : QBWebConnector.WebServiceManager.ReadQWC(string 
fileName) : Unexpected root doc: QBXML

QBWC1051: The new application was not added
20180408.10:10:45 UTC   :  : ~SingleInstanceHandler() - usingInstanceChannel 
= false. Returning without any Registry key delete or unmarshalling.

这是我的客户添加代码。

    string strRequestXML ="";
        XmlDocument inputXMLDoc = null;

        // CustomerQuery
        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 CustomerAddRq = inputXMLDoc.CreateElement("CustomerAddRq");
            qbXMLMsgsRq.AppendChild(CustomerAddRq);
        CustomerAddRq.SetAttribute("requestID", "1");
        XmlElement custAdd = inputXMLDoc.CreateElement("CustomerAdd");
        CustomerAddRq.AppendChild(custAdd);
        custAdd.AppendChild(inputXMLDoc.CreateElement("Name","Naga"));
        custAdd.AppendChild(inputXMLDoc.CreateElement("FirstName", "Nagarajan"));
        custAdd.AppendChild(inputXMLDoc.CreateElement("MiddleName", ""));
        custAdd.AppendChild(inputXMLDoc.CreateElement("LastName", "varatharajan"));
        XmlElement BillAddress = inputXMLDoc.CreateElement("BillAddress");
        custAdd.AppendChild(BillAddress);
        BillAddress.AppendChild(inputXMLDoc.CreateElement("Addr1", "7/78"));
        BillAddress.AppendChild(inputXMLDoc.CreateElement("City", "Chennai"));
        BillAddress.AppendChild(inputXMLDoc.CreateElement("State", "TN"));            
        XmlElement maxReturned = inputXMLDoc.CreateElement("MaxReturned");
        CustomerAddRq.AppendChild(maxReturned).InnerText="1";
        strRequestXML = inputXMLDoc.OuterXml;
        req.Add(strRequestXML);

2 个答案:

答案 0 :(得分:0)

您的.QWC文件无效。

您可以使用QuickBooks SDK附带的XML Validator工具来验证这一点。您可能还想参考StackOverflow上的其他.QWC相关问题,这些问题显示正确构造的.QWC文件。例如:

如果您阅读日志文件,这很明显。你可以看到这个:

QBWebConnector.WebServiceManager.ReadQWC(string fileName) : Unexpected root doc: QBXML

修复.QWC文件(特别是根节点),使其符合规范。

答案 1 :(得分:0)

我看到三件事:

  • QBXML应为QBWCXML
  • 在结束QBXML之后你有一个引用
  • 您在AppURL元素中拼写错误localhost

但是再看看对Keith回答的回答,它看起来像是修复了你的问题,所以你应该把它标记为正确。