Reputation: 55
I was trying to consume a soap service in python with zeep. I've consumed several soap services with zeep as well. But for a particular soap service, a weird response in returning, unlike a well-organized dictionary.
My python code is below:
import zeep
import json
def getToken1():
wsdl2 = 'http://trx.*********ast.co.id/Webservice/b******ervice?wsdl'
client2 = zeep.Client(wsdl2)
parameters = {
'username':'n**l***s',
'password': 'ra8*******PeSw',
'counterpart':'***',
'ipAddress':'127.0.0.1'
}
info = client2.service.requestToken(parameters)
json = zeep.helpers.serialize_object(info, dict)
return json
print(getToken1())
i.e. the credentials are absolutely correct.
Unfortunately the output is below:
Traceback (most recent call last):
File "F:\Maksudul_Hasan\python\python_soapClient\index.py", line 17, in
<module>
print(getToken1())
File "F:\Maksudul_Hasan\python\python_soapClient\index.py", line 13, in
getToken1
info = client2.service.requestToken(parameters)
File
"C:\Users\maksudul.it\AppData\Local\Programs\Python\Python39\lib\site-
packages\zeep\proxy.py", line 46, in __call__
return self._proxy._binding.send(
File
"C:\Users\maksudul.it\AppData\Local\Programs\Python\Python39\lib\site-
packages\zeep\wsdl\bindings\soap.py", line 135, in send
return self.process_reply(client, operation_obj, response)
File
"C:\Users\maksudul.it\AppData\Local\Programs\Python\Python39\lib\site-
packages\zeep\wsdl\bindings\soap.py", line 206, in process_reply
raise TransportError(
zeep.exceptions.TransportError: Server returned response (200) with
invalid XML: Invalid
XML content received (AttValue: " or ' expected, line 77, column 14).
Content: b'\n\t\t<html><head><title>NuSOAP:
Br***stservice</title>\n\t\t<style
type="text/css">\n\t\t body { font-family: arial; color: #000000;
background-color:
#ffffff; margin: 0px 0px 0px 0px; }\n\t\t p { font-family:
arial; color:
#000000; margin-top: 0px; margin-bottom: 12px; }\n\t\t pre {
background-color: silver;
padding: 5px; font-family: Courier New; font-size: x-small; color:
#000000;}\n\t\t ul
....................
It's a large response. But in soapUI :
Request:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:SOAPServerWSDL">
<soapenv:Header/>
<soapenv:Body>
<urn:requestToken
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<parameters xsi:type="urn:requestTokenCT"
xmlns:urn="urn:***stservice">
<!--You may enter the following 4 items in any order-->
<username xsi:type="xsd:string">nbl**s</username>
<password xsi:type="xsd:string">ra8*******4iphEsPeSw</password>
<counterpart xsi:type="xsd:string">N*L</counterpart>
<ipAddress xsi:type="xsd:string">127.0.0.1</ipAddress>
</parameters>
</urn:requestToken>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="urn:Brifastservice">
<SOAP-ENV:Body>
<ns1:requestTokenResponse xmlns:ns1="urn:SOAPServerWSDL">
<return xsi:type="tns:requestTokenCTResult">
<message xsi:type="xsd:string">Success</message>
<statusCode xsi:type="xsd:string">0**01</statusCode>
<token
xsi:type="xsd:string">99B4631DCD445***23BF6CED31C1B6574</token>
</return>
</ns1:requestTokenResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Can anyone help me to get data from this soap service through zeep in python?
Upvotes: 3
Views: 1414
Reputation: 1208
Your requested WSDL URL contains https protocol and you are calling http request.
Please call this url : https://trx.*********ast.co.id/Webservice/b******ervice?wsdl
Upvotes: 3