首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python web2py pysimplesoap客户端信封数据

python web2py pysimplesoap客户端信封数据
EN

Stack Overflow用户
提问于 2017-12-28 19:38:38
回答 1查看 180关注 0票数 0

我正在使用web2py pysimplesoap,并且我尝试从服务器获取数据。在我调用该方法之后,我得到了一个响应,但是xml中没有数据。有什么建议吗?

以下是我的代码

代码语言:javascript
复制
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()

我的结果是

代码语言:javascript
复制
 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>

过了一段时间,我得到了一个超时

代码语言:javascript
复制
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>
EN

回答 1

Stack Overflow用户

发布于 2018-01-04 19:59:03

对于简单的soap,首先我需要设置一个url来获取xml,因为它调用了一些内部URL

代码语言:javascript
复制
client.services['xxx']['ports']['xxx']['location'] = 'https://www.xxx.yyy/demo/gg/gg'

但是由于我有一些xml解析和其他问题,我决定使用zeep库,但我也必须做一些更正。我不知道是否有bug,但是检索数据的调用是错误的,所以我需要更正一些东西(参见代码中的注释)。

代码语言:javascript
复制
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

希望这对某些人有帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48006800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档