Closed FrugoFruit90 closed 8 years ago
Any way I could help with addressing this? (mostly I can try to provide more information/ test things as I'm probably not qualified enough to create my own fix) :) Similar code works with suds-jurko, but unfortunately his project does not support empty elements, which gives me a lot of problems as this particular SOAP uses them a lot.
Do you have the wsdl somewhere (I might be overlooking it).
So what I usually do first when an error occurs during the response handling is creating a script for it, like for example::
import pretend
from zeep import Client
from zeep.transports import Transport
transport = Transport()
client = Client('http://www.visahq.com/wsdl.wsdl', transport=transport)
response = pretend.stub(
status_code=200,
headers=[],
content="""
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:VisaHQTravelService" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:doGetCountriesResponse>
<countries SOAP-ENC:arrayType="ns1:CountryItemType[232]" xsi:type="ns1:CountriesArrayType">
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">AF</code>
<name xsi:type="xsd:string">Afghanistan</name>
</item>
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">AL</code>
<name xsi:type="xsd:string">Albania</name>
</item>
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">DZ</code>
<name xsi:type="xsd:string">Algeria</name>
</item>
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">AS</code>
<name xsi:type="xsd:string">American Samoa</name>
</item>
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">AD</code>
<name xsi:type="xsd:string">Andorra</name>
</item>
<item xsi:type="ns1:CountryItemType">
<code xsi:type="ns1:CountryCodeType">AO</code>
<name xsi:type="xsd:string">Angola</name>
</item>
<!-- ...and many more... -->
</countries>
</ns1:doGetCountriesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
""")
result = client.service._binding.process_reply(
client,
client.service._binding._operations['doGetCountries'],
response)
print(result)
If you could create something like that for your request I can probably fix it pretty quickly
Hello, I really appreciate your help! Here is the wsdl: https://test-dilo.nfz.gov.pl/ws-broker-server-pkus-auth/services/Auth?wsdl This is the code I used when trying to emulate your approach:
transport = Transport(verify=False)
client = Client('https://test-dilo.nfz.gov.pl/ws-broker-server-pkus-auth/services/Auth?wsdl', transport=transport)
response = pretend.stub(
status_code=200,
headers=[],
content="""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns1:session id="37A6660D3B6ECAB97C1D4E9E757061B3" xmlns:ns1="http://xml.kamsoft.pl/ws/common"/>
<ns1:authToken id="BSPApF6asPCpmmBUOuj_13" xmlns:ns1="http://xml.kamsoft.pl/ws/common"/>
</soapenv:Header>
<soapenv:Body>
<ns1:loginReturn xmlns:ns1="http://xml.kamsoft.pl/ws/kaas/login_types">[000] U&#380;ytkownik zosta&#322; prawid&#322;owo zalogowany.</ns1:loginReturn>
</soapenv:Body>
</soapenv:Envelope>
""")
result = client.service._binding.process_reply(client,
client.service._binding._operations['login'],
response)
print(result)
and here we have the traceback (and nothing else in the console except the warning about skipping SSL verification:
Traceback (most recent call last):
File "C:/Users/j.zysko/gabinet/dilo/zeep_utils.py", line 76, in <module>
response)
File "C:\Users\j.zysko\Envs\gabinet\lib\site-packages\zeep\wsdl\soap.py", line 143, in process_reply
return operation.process_reply(doc)
File "C:\Users\j.zysko\Envs\gabinet\lib\site-packages\zeep\wsdl\soap.py", line 276, in process_reply
return self.output.deserialize(body)
File "C:\Users\j.zysko\Envs\gabinet\lib\site-packages\zeep\wsdl\messages.py", line 241, in deserialize
assert elm is not None, '%s not found' % part.element.qname
AssertionError: {http://xml.kamsoft.pl/ws/common}session not found
I guess I'm doing something wrong? Since it's the same traceback as the one that I posted above.
Oh no you are doing it correctly! Thanks! Since now I can easily reproduce it I might be able to fix it pretty quickly. :-)
This turns out to be related to #180. I'm closing this one in favour of that one.
Hey, this is excellent :) Waiting for the next version, keep up with the good work! Cheers
@FrugoFruit90 are you able to test #205 ?
@mvantellingen yes the service in #177 now works correctly, thank you very much! And sorry for taking so long, was my first time cloning a pull request so I actually had to find an hour to figure out how to do it.
Hey! The information in the response (loginReturn ) means (in Polish): "The user has logged in correctly ". Nevertheless, I get the following error:
Below is the server response - the one that is being parsed incorrectly (same as above but from SoapUI which formats it nicely):
The comment in the DocumentMessage(SoapMessage) function says:
In the document message there are no additional wrappers, and the message parts appear directly under the SOAP Body element.
So I guess the problem is that there is a wrapper inside the wrapper. Any idea how to fix it?