我最近接受了一项(残酷且血腥的)任务,即使用 python 3.3 为 Microsoft Dynamics GP 10 Web 服务开发 SOAP 客户端。经过一天左右的 wsdl 切片和切 block 后,我终于能够使用 suds-jurko 创建一个客户端。我可以创建 wsdl 中定义的对象(类型)并与之交互。但是,当我尝试进行任何服务调用时,我不可避免地会收到 400 Bad Request 错误。经过半天的研究,我怀疑这与 Dynamics GP 10 Web 服务使用的 wsHttpBinding 有关(旧版 wsdl,使用 basicHttpBinding 工作得很好)。
首先,谁能帮我确认一下suds-jurko是否支持wsHttpBinding?我怀疑事实并非如此,但我希望以某种方式得到确认,以便我知道我是否在朝着正确的方向前进。
其次,假设suds-jurko不支持wsHttpBinding,我需要做什么才能向suds-jurko添加对wsHttpBinding的支持?我了解 basicHttpBinding 和 wsHttpBinding 之间的基本区别,但我很难找到有关 SOAP 客户端在这两种绑定(bind)场景中需要做什么的具体资源(我在网上找到的绝大多数资源都是关于如何配置 .NET Web 服务以使用 wsHttpBinding,这对我来说没有用)。
这是我当前的客户发送的请求。此请求与支持 wsHttpBinding 的客户端生成的请求有何不同(或有何不同)?
HEADERS: {'Content-Type': 'application/soap+xml; charset=utf-8',
'Content-type': 'application/soap+xml; charset=utf-8',
'SOAPAction': b'"http://schemas.microsoft.com/dynamics/gp/2010/01/ICompany/GetCompanyList"',
'Soapaction': b'"http://schemas.microsoft.com/dynamics/gp/2010/01/ICompany/GetCompanyList"'}
MESSAGE: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns0="http://schemas.microsoft.com/dynamics/gp/2010/01"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.GP"
xmlns:ns3="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.Common"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetCompanyList>
<ns0:criteria>
<ns3:columns/>
<ns3:convertToUpperCaseRestriction/>
<ns3:restrictions/>
<ns2:Id>
<ns3:From>-32000</ns3:From>
<ns3:To>32000</ns3:To>
</ns2:Id>
</ns0:criteria>
<ns0:context>
<ns3:CultureName>en-US</ns3:CultureName>
<ns3:CurrencyType>Transactional</ns3:CurrencyType>
<ns3:OrganizationKey xsi:type="ns3:CompanyKey">
<ns3:Id>-1</ns3:Id>
</ns3:OrganizationKey>
</ns0:context>
</ns0:GetCompanyList>
</ns1:Body>
</SOAP-ENV:Envelope>
(我注意到重复的 header ,想知道这是否可能与 400 Bad Request 错误有关。我尝试了与 suds-jurko 使用 urllib.request 使用的代码几乎相同的代码,但最终仍然出现 400: Bad Request没有重复标题的错误)
如有任何建议和/或建议,我们将不胜感激。如果您想从我这里获得更多信息,我将非常乐意提供我所能提供的信息。提前致谢。
最佳答案
经过大量研究、实验和测试,我找到了大部分问题的答案。希望有人能从我学到的东西中受益。我们最终选择了旧端点。
回答我的第一个问题,suds-jurko 不支持 wsHTTPBinding。我不确定 .NET 世界之外是否有任何作用。
添加对 suds-jurko 的 wsHTTPBinding 支持将是一项艰巨的任务。您应该能够找到有关基本 wsHTTPBinding 规范的信息 here和 here .
关于使用 suds-jurko 的 Dynamics GP 的 Python 3 SOAP 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23096953/