我正在使用web2py pysimplesoap,我尝试从服务器获取数据。在我调用该方法后,我得到一个响应,但xml中没有数据。 有什么建议吗?
这是我的代码
url = "https://www.xxx.ss/demo/aaa/aaa"
#
xml = ("""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cet="http://xxxx.yy">
<soapenv:Header/>
<soapenv:Body>
<cet:GetEmployedElement>
<!--Zero or more repetitions:-->
<cet:GetEmployed>
<cet:OrganizationCode></cet:OrganizationCode>
<cet:LastName></cet:LastName>
<cet:FirstName></cet:FirstName>
<cet:AktCard></cet:AktCard>
<cet:JobAgreementType></cet:JobAgreementType>
<cet:Mferac></cet:Mferac>
</cet:GetEmployed>
</cet:GetEmployedElement>
</soapenv:Body>
</soapenv:Envelope>
""")
from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault
client = SoapClient(wsdl="https://www.xxxx.yy/demo/aaa/aaa?wsdl", location="https://www.xxxx.yy", cacert=None, trace=True)
# call SOAP method
#print server.methods['getEmployed']
#print client
print client.getEmployed()
我的结果是
POST http://192.168.66.53:8380/demo/KadrisData/KadrisData
SOAPAction: "http://cetrtapot.si/getEmployed"
Content-length: 269
Content-type: text/xml; charset="UTF-8"
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
</soap:Body>
</soap:Envelope>
过了一会儿我用
超时了urllib2.URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
答案 0 :(得分:0)
首先使用简单的soap我需要设置一个url来获取xml,因为它调用了一些内部URL
client.services['xxx']['ports']['xxx']['location'] = 'https://www.xxx.yyy/demo/gg/gg'
但由于我有一些xml解析和其他问题我决定使用zeep库,但我也不得不做一些修正。我不知道是否有错误,但是检索数据的调用是错误的,所以我需要更正一些东西(参见代码中的注释)
client = Client(url ,strict=False)
#In case some parameters expected from envelope were missing I got an error, so I needed to set strict = False
x = client.service.getEmployed
x._proxy._binding_options['address'] = 'https://www.xxxx.yyyy/demo/gggg/gggta'
#a new binding option neede to be set otherwise some internal 192.168.xx.yy was called and that is why I always got an timeout error
希望这有助于某人