3

I do :

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

client return 58 methods. But when I want use method CzyZalogowany program return:

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

How to to resolve?

#

DUBUG from SoupUi:

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>"

Debug from python script:

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--'}

Maybe this is due to the lack of a namespace. How to add namespace?

user7172
  • 874
  • 4
  • 16
  • 31
  • Does the ssl layer work? Does the rest call work in isolation (browser, curl, wget)? Maybe the things that "CzyZalogowany" (whatever this means) tries to do take more time, need a parameter, ... Please provide more detail. – Dilettant Jun 24 '16 at 11:52
  • Does the ssl layer work? - how to check? I test wsdl in SoapUI and its work.Return true – user7172 Jun 24 '16 at 12:08
  • If you're using SoapUI, you probably need to enable client certificates to test SSL. See http://stackoverflow.com/questions/13994164/soapui-certificate-authentication. – Peter Brittain Jun 29 '16 at 11:52
  • In SoupUi work perfect. The problem is on the side of python. – user7172 Jun 29 '16 at 12:35
  • I get that... My comment was in answer to your question on how you can check whether SSL is working correctly. – Peter Brittain Jun 29 '16 at 17:49
  • 2
    please, tell me how you have calculated "Content-Length" :"1086"? maybe server just waits for more data? remove this header... I'll leave only "Authorization".. – Jerzyk Jun 29 '16 at 20:01
  • Well, there are a few differences between the SoupUI and Python XML documents, the most notable being that SoupUI includes `http://tempuri.org/ITerytWs1/CzyZalogowany` in the header, which Python doesn't. However, it's not really possible to check if this is the problem without a valid userid/password combination. – Aya Jul 04 '16 at 16:09
  • I have a problem with this web service as well, how are you able to connect to it using soap ui? Please see my question https://stackoverflow.com/questions/45347681/integrating-with-teryt-polish-government-web-service/45369353#45369353 I am using the test user from the official documentation, and it returns the soapfault. – msi Jul 30 '17 at 19:33

1 Answers1

1

I've had the same problem with this specific webservice at uslugaterytws1test.stat.gov.pl. The solution was to change SOAP-ENV namespace to soapenv.

Grzegorz Adam Kowalski
  • 5,243
  • 3
  • 29
  • 40