使用Python/Sypn时找不到Quickbooks Web Connector SOAP请求的资源

2024-06-09 18:32:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图编写一个pythonweb服务来与quickbookswebconnector集成。Im使用spyneapi来实现这一点,但似乎遇到了一个无法识别请求的方法的问题。我写的代码是:

class QuickbooksSOAPService(ServiceBase):
    __tns__ = 'http://developer.intuit.com'

    @srpc(Unicode, Unicode, _returns=Array(Unicode), 
            _operation_name="http://developer.intuit.com/authenticate")
    def authenticate(strUserName, strPassword):

        print strUserName
        return ['','','','']

application = Application(
    [QuickbooksSOAPService], tns='http://developer.intuit.com',
    in_protocol = Soap11(),
    out_protocol = Soap11(),
    )

wsgi_application = WsgiApplication(application)

我通过Flask框架发布这些web服务,我在我的网站的其余部分都使用这个框架

^{pr2}$

我注意到spyne生成的wsdl定义与官方wsdl的定义存在一些差异,例如:

间谍:

<wsdl:operation name="http://developer.intuit.com/authenticate">
    <soap:operation soapAction="http://developer.intuit.com/authenticate" style="document"/>
    <wsdl:input name="authenticate">
        <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output name="authenticateResponse">
        <soap:body use="literal"/>
    </wsdl:output>
</wsdl:operation>

正确的intuit版本:

<wsdl:operation name="authenticate">
    <soap:operation soapAction="http://developer.intuit.com/authenticate" style="document"/>
    <wsdl:input>
        <soap:body use="literal"/>
    </wsdl:input><wsdl:output>
        <soap:body use="literal"/>
    </wsdl:output>
</wsdl:operation>

以下是调试日志中弹出的内容

[2016-11-24 19:15:27,650] p6534 {/var/www/jumpr/env_dev_jumpr/local/lib/python2.7/site-packages/spyne/protocol/soap/soap11.py:105} DEBUG - ValueError: Deserializing from unicode strings with encoding declaration is not supported by lxml.
[2016-11-24 19:15:27,651] p6534 {/var/www/jumpr/env_dev_jumpr/local/lib/python2.7/site-packages/spyne/protocol/xml.py:356} DEBUG - Method request string: {http://developer.intuit.com/}authenticate
[2016-11-24 19:15:27,651] p6534 {/var/www/jumpr/env_dev_jumpr/local/lib/python2.7/site-packages/spyne/protocol/xml.py:357} DEBUG - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <authenticate xmlns="http://developer.intuit.com/">
      <strUserName>jumpadmin</strUserName>
      <strPassword>aaa</strPassword>
    </authenticate>
  </soap:Body>
</soap:Envelope>

[2016-11-24 19:15:27,652] p6534 {/var/www/jumpr/env_dev_jumpr/local/lib/python2.7/site-packages/spyne/protocol/xml.py:574} DEBUG - Response <soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap11env:Body>
    <soap11env:Fault>
      <faultcode>soap11env:Client.ResourceNotFound</faultcode>
      <faultstring>Requested resource '{http://developer.intuit.com/}authenticate' not found</faultstring>
      <faultactor></faultactor>
    </soap11env:Fault>
  </soap11env:Body>
</soap11env:Envelope>

SOAP操作名和SOAP操作名之间的差异是否会导致“找不到请求的资源”问题?还是我错过了更明显的东西?在


Tags: namecomhttpdeveloperwwwoperationprotocolsoap