使用suds-jurko的Python 3 Dynamics GP SOAP客户端
最近,我被分配了一个非常棘手的任务,就是用Python 3.3为Microsoft Dynamics GP 10的网络服务开发一个SOAP客户端。经过一天的努力,我终于用suds-jurko创建了一个客户端,可以创建和操作在wsdl中定义的对象(类型)。不过,当我尝试进行任何服务调用时,总是会收到一个400错误,提示请求错误。经过半天的研究,我怀疑这可能和Dynamics GP 10网络服务使用的wsHttpBinding有关(而使用basicHttpBinding的旧版wsdl就没问题)。
首先,有人能确认一下suds-jurko是否支持wsHttpBinding吗?我怀疑它不支持,但我希望能得到确认,这样我就知道自己是否在正确的方向上。
其次,假设suds-jurko确实不支持wsHttpBinding,那我需要做些什么才能让suds-jurko支持wsHttpBinding呢?我了解basicHttpBinding和wsHttpBinding之间的基本区别,但我很难找到具体的资源,说明SOAP客户端在这两种绑定情况下需要做什么不同的事情(我在网上找到的大部分资源都在讲如何配置.NET网络服务使用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>
(我注意到重复的头信息,想知道这是否和400错误有关。我尝试了几乎相同的代码,使用urllib.request,但还是得到了400: Bad Request错误,且没有重复的头信息)
任何建议或意见都将不胜感激。如果你需要我提供更多信息,我会很乐意提供。提前谢谢你们。