Python SOAP客户端嵌套请求

Python SOAP客户端嵌套请求,python,soap,request,Python,Soap,Request,我遇到了Python SOAP请求的问题。 到目前为止,我测试了两个pythonsoap客户端库:SUDS和pysimplesoap。 对于以下示例,这两种方法都很有效: from suds.client import Client from pysimplesoap.client import SoapClient, SoapFault # suds example url = "http://www.webservicex.net/geoipservice.asmx?WSDL" clien

我遇到了Python SOAP请求的问题。 到目前为止,我测试了两个pythonsoap客户端库:SUDS和pysimplesoap。 对于以下示例,这两种方法都很有效:

from suds.client import Client
from pysimplesoap.client import SoapClient, SoapFault

# suds example
url = "http://www.webservicex.net/geoipservice.asmx?WSDL"
client = Client(url, cache=None)

print client.service.GetGeoIP((ip))


# pysimplesoap example
client = SoapClient(wsdl="http://www.webservicex.net/geoipservice.asmx?WSDL")

# call the remote method
response = client.GetGeoIP(("10.0.1.152"))

print response
两者都很好,并给我预期的响应:

{'GetGeoIPResult': {'ReturnCodeDetails': 'Success', 'IP': '10.0.1.152', 'ReturnCode': 1, 'CountryName': 'Reserved', 'CountryCode': 'ZZZ'}}
对于UI SOAP测试程序,请求如下所示:

-<soap:Envelope>
    -<soap:Body>
        -<GetGeoIP>
            <IPAddress>("10.0.1.152")</IPAddress>
        </GetGeoIP>
    </soap:Body>
</soap:Envelope>
我得到:

ValueError('Invalid Args Structure. Errors: %s' % errors)
ValueError: Invalid Args Structure. Errors:

我必须如何正确地嵌套我的请求?

我终于解决了它。肥皂水图书馆提供了一些不错的东西:

url = "xxxxxxxxxxxxxxxxxxxxxxxxx?wsdl"
client = Client(url, cache=None)

# Creating 'shrequest' obj. before the request
shrequest = client.factory.create('shrequest')
shrequest.data = "{'account_number':202VA7, 'track_nr':1757345939}"
shrequest.function = "getnewsdata"

response = client.service.getShipment(shrequest)

print response

您可能希望将
{'account\u number':202VA7
更改为
{'account\u number':'202VA7'
,感谢您的响应,但由于数据是一个完整的字符串,这并不重要。它与我在UI程序中使用的参数相同,在那里也可以正常工作。
ValueError('Invalid Args Structure. Errors: %s' % errors)
ValueError: Invalid Args Structure. Errors:
url = "xxxxxxxxxxxxxxxxxxxxxxxxx?wsdl"
client = Client(url, cache=None)

# Creating 'shrequest' obj. before the request
shrequest = client.factory.create('shrequest')
shrequest.data = "{'account_number':202VA7, 'track_nr':1757345939}"
shrequest.function = "getnewsdata"

response = client.service.getShipment(shrequest)

print response