Quickbooks - sendRequestXML - > com.sun.istack.SAXException2

时间:2013-07-18 16:22:30

标签: quickbooks

我正在为quickbooks web连接器实现webservice。 这是我的sendRequestXML方法..到目前为止仅用于测试。

@Override
@WebResult(name = "sendRequestXMLResult", targetNamespace = "http://developer.intuit.com/")
@RequestWrapper(localName = "sendRequestXML", targetNamespace = "http://developer.intuit.com/", className = "com.intuit.developer.SendRequestXML")
@WebMethod(action = "http://developer.intuit.com/sendRequestXML")
@ResponseWrapper(localName = "sendRequestXMLResponse", targetNamespace = "http://developer.intuit.com/", className = "com.intuit.developer.SendRequestXMLResponse")
public String sendRequestXML(@WebParam(name = "ticket", targetNamespace = "http://developer.intuit.com/") String ticket,
        @WebParam(name = "strHCPResponse", targetNamespace = "http://developer.intuit.com/") String strHCPResponse,
        @WebParam(name = "strCompanyFileName", targetNamespace = "http://developer.intuit.com/") String strCompanyFileName,
        @WebParam(name = "qbXMLCountry", targetNamespace = "http://developer.intuit.com/") String qbXMLCountry,
        @WebParam(name = "qbXMLMajorVers", targetNamespace = "http://developer.intuit.com/") int qbXMLMajorVers,
        @WebParam(name = "qbXMLMinorVers", targetNamespace = "http://developer.intuit.com/") int qbXMLMinorVers) {
    String result = "";
    StringWriter writer;
    try {
        QBXML qbxml = new QBXML();
        QBXMLMsgsRq qbxmlMsgsRq = new QBXMLMsgsRq();
        List<Object> hostQueryRqOrCompanyQueryRqOrAccountAddRq = qbxmlMsgsRq.getHostQueryRqOrCompanyQueryRqOrAccountAddRq();
        InvoiceAdd invoiceAdd = new InvoiceAdd();
        List<Object> invoiceLineAddOrInvoiceLineGroupAdd = invoiceAdd.getInvoiceLineAddOrInvoiceLineGroupAdd();
        InvoiceLineAdd invoiceLineAdd = new InvoiceLineAdd();
        invoiceLineAdd.setAmount("100");
        invoiceLineAdd.setDesc("Programming book");
        invoiceLineAdd.setQuantity("1");
        SalesTaxCodeRef salesTaxCodeRef = new SalesTaxCodeRef();
        invoiceLineAdd.setSalesTaxCodeRef(salesTaxCodeRef);
        invoiceLineAddOrInvoiceLineGroupAdd.add(invoiceLineAdd);
        hostQueryRqOrCompanyQueryRqOrAccountAddRq.add(invoiceAdd);
        qbxml.setQBXMLMsgsRq(qbxmlMsgsRq);
        JAXBContext context = JAXBContext.newInstance(QBXML.class);
        Marshaller marshaller = context.createMarshaller();
        writer = new StringWriter();
        marshaller.marshal(qbxml, writer);
        String xml = writer.toString();
        result = xml;
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return result;
}

当我进行测试时,我得到:

引起:com.sun.istack.SAXException2:“com.intuit.xsd.generated.InvoiceAdd”的实例替换为“java.lang.Object”,但“com.intuit.xsd.generated.InvoiceAdd”是绑定到匿名类型。

发现问题......

QBXML qbxml = new QBXML();
QBXMLMsgsRq qbxmlMsgsRq = new QBXMLMsgsRq();
qbxmlMsgsRq.setOnError("stopOnError");
List<Object> hostQueryRqOrCompanyQueryRqOrAccountAddRq =   qbxmlMsgsRq.getHostQueryRqOrCompanyQueryRqOrAccountAddRq();
InvoiceAddRqType invoiceAddRqType = new InvoiceAddRqType();
invoiceAddRqType.setRequestID("1");
InvoiceAdd invoiceAdd = new InvoiceAdd();
CustomerRef customerRef = new CustomerRef();
customerRef.setFullName("ONP");
invoiceAdd.setCustomerRef(customerRef);
List<Object> invoiceLineAddOrInvoiceLineGroupAdd = invoiceAdd.getInvoiceLineAddOrInvoiceLineGroupAdd();
InvoiceLineAdd invoiceLineAdd = new InvoiceLineAdd();
ItemRef itemRef = new ItemRef();
itemRef.setFullName("Programming book");
invoiceLineAdd.setItemRef(itemRef);
invoiceLineAdd.setAmount("100");
invoiceLineAdd.setDesc("Programming book");
invoiceLineAdd.setQuantity("1");
SalesTaxCodeRef salesTaxCodeRef = new SalesTaxCodeRef();
invoiceLineAdd.setSalesTaxCodeRef(salesTaxCodeRef);
invoiceLineAddOrInvoiceLineGroupAdd.add(invoiceLineAdd);
invoiceAddRqType.setInvoiceAdd(invoiceAdd);
hostQueryRqOrCompanyQueryRqOrAccountAddRq.add(invoiceAddRqType);
qbxml.setQBXMLMsgsRq(qbxmlMsgsRq);
JAXBContext context = JAXBContext.newInstance(QBXML.class);
Marshaller marshaller = context.createMarshaller();
writer = new StringWriter();
marshaller.marshal(qbxml, writer);
String xml = writer.toString();
result = xml;

现在quickbooks收到了消息,但我在Web连接器中收到此错误。

“QuickBooks在解析提供的XML文本流时发现错误”

但错误在哪里......

0 个答案:

没有答案