1

我正在尝试编写一个 python Web 服务来与 Quickbooks Web 连接器集成。我使用 Spyne api 来执行此操作,但似乎遇到了无法识别请求方法的问题。我写的代码是:

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 服务,我在我的网站的其余部分使用,就像这样

app_obj.wsgi_app = DispatcherMiddleware(app_obj.wsgi_app, {
        '/qbwcwebservices': qbwcwebservices })

我注意到 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>

正确的直觉版本:

<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 操作名称的差异会导致此“未找到请求的资源”问题吗?还是我错过了更明显的东西?

4

0 回答 0