【问题标题】:Error with connecting to wsdl?连接到 wsdl 时出错?
【发布时间】:2016-10-26 23:58:16
【问题描述】:

我愿意:

base64string = base64.encodestring('%s:%s' % (userid, passwd)).replace('\n', '')
authenticationHeader = {
    "Authorization" : "Basic %s" % base64string,
"Accept-Encoding" :"gzip,deflate",
"Content-Length" :"1086",
"Host" :"uslugaterytws1test.stat.gov.pl",
"Connection" :"Keep-Alive",
}

client = Client(url=wsdl_url, headers=authenticationHeader)
security = Security()

token = UsernameToken(userid, passwd)
token.setnonce('MyNonceString...')
token.setcreated(datetime.now())
security.tokens.append(token)
client.set_options(wsse=security)

result = client.service.CzyZalogowany()
print result

客户端返回 58 个方法。 但是当我想使用方法 CzyZalogowany 程序返回时:

ssl.SSLError: ('The read operation timed out',)

如何解决?

#

来自 SoupUi 的 DUBUG:

DEBUG:>> "POST /TerytWs1.svc HTTP/1.1[\r][\n]"
DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]"
DEBUG:>> "SOAPAction: "http://tempuri.org/ITerytWs1/CzyZalogowany"[\r][\n]"
DEBUG:>> "Authorization: Basic --XXXX--[\r][\n]"
DEBUG:>> "Content-Length: 1086[\r][\n]"
DEBUG:>> "Host: uslugaterytws1test.stat.gov.pl[\r][\n]"
DEBUG:>> "Connection: Keep-Alive[\r][\n]"
DEBUG:>> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
DEBUG:>> "[\r][\n]"
DEBUG:>> "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">[\n]"
DEBUG:>> "   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-1EDC585567575555675433"><wsse:Username>--USER--</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">--PASSWORD--</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">ffoUxdsf49tsdLryxWufW==</wsse:Nonce><wsu:Created>2016-06-28T09:14:05.995Z</wsu:Created></wsse:UsernameToken></wsse:Security><wsa:Action>http://tempuri.org/ITerytWs1/CzyZalogowany</wsa:Action></soapenv:Header>[\n]"
DEBUG:>> "   <soapenv:Body>[\n]"
DEBUG:>> "      <tem:CzyZalogowany/>[\n]"
DEBUG:>> "   </soapenv:Body>[\n]"
DEBUG:>> "</soapenv:Envelope>"

从 python 脚本调试:

DEBUG:suds.client:sending to (https://uslugaterytws1test.stat.gov.pl/TerytWs1.svc)
message:
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns0="http://tempuri.org/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <wsse:Security mustUnderstand="true">
         <wsse:UsernameToken>
            <wsse:Username>--USER--</wsse:Username>
            <wsse:Password>--PASSWORD--</wsse:Password>
            <wsse:Nonce>MyNonceString...</wsse:Nonce>
            <wsu:Created>2016-06-28T13:16:17.180000Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:CzyZalogowany/>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'Content-Length': '1086', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip,deflate', 'SOAPAction': u'"http://tempuri.org/ITerytWs1/CzyZalogowany"', 'Content-Type': 'text/xml; charset=utf-8', 'Host': 'uslugaterytws1test.stat.gov.pl', 'Authorization': 'Basic --XXXX--'}

这可能是由于缺少命名空间。如何添加命名空间?

【问题讨论】:

  • ssl层能用吗?其余调用是否单独工作(浏览器、curl、wget)?也许“CzyZalogowany”(无论这意味着什么)尝试做的事情需要更多时间,需要一个参数,......请提供更多细节。
  • ssl层能用吗? - 如何检查?我在 SoapUI 及其工作中测试 wsdl。返回 true
  • 如果您使用的是 SoapUI,您可能需要启用客户端证书来测试 SSL。见stackoverflow.com/questions/13994164/…
  • 在 SoupUi 中完美运行。问题出在 python 一边。
  • 请告诉我您是如何计算“Content-Length”:“1086”的?也许服务器只是等待更多数据?删除此标题...我将只留下“授权”..

标签: python wsdl suds


【解决方案1】:

我在uslugaterytws1test.stat.gov.pl 遇到了同样的问题。解决方案是将SOAP-ENV 命名空间更改为soapenv

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-04
    • 2013-04-11
    相关资源
    最近更新 更多