QuickBooks Web Connector is sending the QuickBooks found an error when parsing the provided XML text stream.
message to my receiveResponseXML method even though my xml checks out in the qb*XML Validator. I have included the authenticate and sendRequestXML methods from my QBTalker class below (other required methods are also in the class; QB Web Connector talks to clientVersion, authenticate, sendRequestXML in that order before sending the hresult value 0x80040400
and the message value QuickBooks found an error when parsing the provided XML text stream.
to receiveResponseXML):
class QBTalker(ServiceBase):
qbxml_version = ''
request_seq_no = 0
ticket_id = ''
@srpc(String, String, _returns=Iterable(String))
def authenticate(user, pswd):
#ticket_id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(50))
QBTalker.ticket_id = 'COMPANY NAME IN QUICKBOOKS'
for each in [QBTalker.ticket_id, '', '', '']:
yield each
@srpc(String, String, String, String, UnsignedInteger, UnsignedInteger, _returns=String)
def sendRequestXML(id, strHCPResponse, strCompanyFileName, qbXMLCountry, qbXMLMajorVers, qbXMLMinorVers):
'''if id != QBTalker.ticket_id:
return -1
else:
'''
qbxml_version = str(qbXMLMajorVers) + '.' + str(qbXMLMinorVers)
QBTalker.request_seq_no += 1
xml = '''<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerQueryRq requestID="2">
<FullName>COMPANY NAME IN QUICKBOOKS</FullName>
</CustomerQueryRq>
</QBXMLMsgsRq>
</QBXML>
'''
QBTalker.request_seq_no = 99
root = lxml.etree.fromstring(xml)
return lxml.etree.tostring(root)
@srpc(String, String, String, String, _returns=Integer8)
def receiveResponseXML(ticket, response, hresult, message):
response = response
hresult = hresult
message = message
return 100
@srpc(String, String, String, _returns=String)
def connectionError(ticket, hresult, message):
print("QuickBooks Web Connector says a connection error has occurred.")
print("hresult is " + hresult)
print("message is " + message)
@srpc(String, _returns=String)
def getLastError(ticket):
print("QuickBooks Web Connector is asking for the last error on ticket id " + ticket if ticket else "None")
return ticket
@srpc(String, _returns=String)
def closeConnection(ticket):
print("QuickBooks Web Connector is closing the connection for ticket id " + ticket if ticket else "None")
return ticket
if __name__=='__main__':
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)
app = Application([QBTalker], tns='http://developer.intuit.com/',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11(encoding='UTF-8', xml_declaration=True),
)
wsgi_app = WsgiApplication(app)
server = make_server('localhost', 7789, wsgi_app)
server.serve_forever()
UPDATE: Ok, I got the "QuickBooks found an error when parsing the provided XML text stream" error to go away by adding the following import statement
from spyne.model.primitive import AnyXml
and changing the decorator line above my def sendRequestXML line from
@srpc(String, String, String, String, UnsignedInteger, UnsignedInteger, _returns=String)
to
@srpc(String, String, String, String, UnsignedInteger, UnsignedInteger, _returns=AnyXml)
I think this may change the mime type from text/html to text/xml, but I am not sure. I also changed
def authenticate(user, pswd):
to
def authenticate(strUserName, strPassword):
and
def sendRequestXML(id, strHCPResponse, strCompanyFileName, qbXMLCountry, qbXMLMajorVers, qbXMLMinorVers):
to
def sendRequestXML(ticket, strHCPResponse, strCompanyFileName, qbXMLCountry, qbXMLMajorVers, qbXMLMinorVers):
as I now understand the names of the function arguments are specific.
However, I am still getting nothing returned from my query. Can anyone point out what I should change? I am using the same value as would be entered for the NAME field in a !CUST iif file for the COMPANY NAME IN QUICKBOOKS in my code above. Thanks in advance for any help.