Hello,
I have a SOAP request using python-zeep (like it very much, it's like 10 times faster than suds!) which returns the XML response fine, but it doesn't show up when calling the operation via the zeep client.service
I hope the details below are enough to have a look on what's going wrong
I did follow this 'hack' to get to the raw content anyways (other calls are working just fine, so only needed a quick solution for this one call to fix): http://stackoverflow.com/questions/40367295/get-data-from-soap-envelope-zeep
Found it a nice idea to have in the main code, for if someone decides the raw xml is needed ... or can I find it somewhere else already?
Anyways, see below for the details,
Thanks already for having a look!
J.
Prefixes:
ns0: http://www.cisco.com/AXL/API/10.5
xsd: http://www.w3.org/2001/XMLSchema
Global elements:
ns0:executeSQLQuery(sql: xsd:string, sequence: xsd:unsignedLong)
ns0:executeSQLQueryResponse(return: {row: xsd:anyType[]}, sequence: xsd:unsignedLong)
Global types:
ns0:ExecuteSQLQueryReq(sql: xsd:string, sequence: xsd:unsignedLong)
ns0:ExecuteSQLQueryRes(return: {row: xsd:anyType[]}, sequence: xsd:unsignedLong)
Bindings:
Soap11Binding: {http://www.cisco.com/AXLAPIService/}AXLAPIBinding
Service: AXLAPIService
Port: AXLPort (Soap11Binding: {http://www.cisco.com/AXLAPIService/}AXLAPIBinding)
Operations:
executeSQLQuery(sql: xsd:string, sequence: xsd:unsignedLong) -> body: {return: {row: xsd:anyType[]}, sequence: xsd:unsignedLong}, header: {}
import pretend
from zeep import Client
client = Client('schema\current\AXLAPI.wsdl')
response = pretend.stub(
status_code=200,
headers=[],
content="""
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:executeSQLQueryResponse xmlns:ns="http://www.cisco.com/A
XL/API/10.5"><return><row><pkid>fc42d134041a68</pkid><assocpc/><firstname>Joe</firstname><middlename/><lastname>Doe</lastname><userid>joedoe</userid><department>51007</department>
<enablemobility>f</enablemobility><remotedestinationlimit>4</remotedestinationlimit><ocsprimaryuseraddress/><enableemcc>f</enableemcc><fkucservicepro
file/><directoryuri/><islocaluser>t</islocaluser><fkucuserprofile/><enablecalendarpresence>f</enablecalendarpresence><enablecups>f</enablecups><primarynodeid/><keypadenteredalternateidenti
fier/><discoveryuseridentity/><displayname/><enableusertohostconferencenow>f</enableusertohostconferencenow><conferencenowaccesscode/><userrank>1</userrank></row></return></ns:executeSQLQu
eryResponse></soapenv:Body></soapenv:Envelope>
""")
operation = client.service._binding._operations['executeSQLQuery']
result = client.service._binding.process_reply(
client, operation, response)
print(result)
My output looks like:
{
'return': {
'row': []
},
'sequence': None
}
Is there a chance to show the response xml? I think that I have the same problem.
In my case I was able to get the response by using history plugin.
import zeep.plugins
from lxml import etree
history = zeep.plugins.HistoryPlugin()
client = zeep.Client('<path to the wsdl>', plugins=[history])
client.service.methodName()
print(etree.tounicode(history.last_received['envelope'], pretty_print=True))
The problem that I'm facing is that in the returned XML there are elements which are referenced by ID in the places where they should be. Probably when zeep is parsing the returned XML does not look for these references.
When I'm using suds (Jurko's fork) everything is working.
@JanSeynaeve, to reproduce I really need the wsdl. Thanks for the example script however
@mvantellingen , I'm facing a very similar problem, and I would like to contribute with my example script and wsdl file.
Any help will be very appreciated.
Archive.zip
@vstoykov the return xml is what's in the code example (content)
@mvantellingen I mailed some links for the wsdl, it's not a 'public' service ...
Regards,
Jan.
Should be fixed, let me know otherwise
I'm closing this ticket for now as it should be fixed. If there are still any issues then please let me know so that I can re-open the issue.
@mvantellingen In my case it looks like that the response is RPC encoded. More info: http://stackoverflow.com/questions/4510101/soap-href-xml-mapping-problem-which-mapping-helps and https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/bc19050_.htm (Multi-reference)
As stated in the stackoverflow answer:
It's RPC/Encoded format of SOAP which is no longer supported by main frameworks. you have to use Axis (1) to deal with this stuff.
Probably there is no need this to be supported in Zeep. I will stick with suds (Jurko's Fork) for this particular project.
hi @vstoykov, zeep should support rpc encoded messages. If you have a wsdl and raw dump of the xml I can definitely take a look (if suds support it then there is no reason that zeep shouldn't).
If you want, can you open up a new ticket for this?
I will try to extract and construct wsdl with soap message that will work on suds and not in Zeep, because I'm not sure if I can show you the original WSDL and Response because it is internal corporate thing. When I'm ready I will open another Issue with details.
EDIT: Nevermind. I just figured out that the BMC WSDL is wrong. :(
Hi,
I'm still having trouble with this issue.
1. The version of zeep (or if you are running master the commit hash/date)
1.0.0
2. The WSDL you are using
3. An example script
This is a piece of code to demonstrate how I'm parsing the response manually, in order to keep my development.
namespaces = {'soapenv':'http://schemas.xmlsoap.org/soap/envelope/', 'ns0':'urn:HPD_IncidentInterface_WS'}
response = service.HelpDesk_QueryList_Service(Qualification='my filter', startRecord=0, maxLimit=100, _soapheaders=[header])
xml = history.last_received['envelope']
for node in xml.xpath('/soapenv:Envelope/soapenv:Body/ns0:HelpDesk_QueryList_ServiceResponse/ns0:getListValues', namespaces = namespaces):
record_dict = {'Incident_Number': node.xpath('./ns0:Incident_Number', namespaces = namespaces)[0].text.encode('utf-8'),
'Summary': node.xpath('./ns0:Summary', namespaces = namespaces)[0].text.encode('utf-8'),
'Notes': node.xpath('./ns0:Notes', namespaces = namespaces)[0].text.encode('utf-8'),
'Assigned_Support_Company': node.xpath('./ns0:Assigned_Support_Company', namespaces = namespaces)[0].text.encode('utf-8'),
'Assigned_Group': node.xpath('./ns0:Assigned_Group', namespaces = namespaces)[0].text.encode('utf-8'),
'Assignee': node.xpath('./ns0:Assignee', namespaces = namespaces)[0].text.encode('utf-8') if node.xpath('./ns0:Assignee', namespaces = namespaces)[0].text is not None else '',
'Impact': node.xpath('./ns0:Impact', namespaces = namespaces)[0].text.encode('utf-8'),
'Priority': node.xpath('./ns0:Priority', namespaces = namespaces)[0].text.encode('utf-8'),
'Urgency': node.xpath('./ns0:Urgency', namespaces = namespaces)[0].text.encode('utf-8'),
'Status': node.xpath('./ns0:Status', namespaces = namespaces)[0].text.encode('utf-8'),
'Status_Reason': node.xpath('./ns0:Status_Reason', namespaces = namespaces)[0].text.encode('utf-8') if node.xpath('./ns0:Status_Reason', namespaces = namespaces)[0].text is not None else '',
'HPD_CI': node.xpath('./ns0:HPD_CI', namespaces = namespaces)[0].text.encode('utf-8'),
'Submit_Date': dateutil.parser.parse(node.xpath('./ns0:Submit_Date', namespaces = namespaces)[0].text.encode('utf-8')),
'Resolution': node.xpath('./ns0:Resolution', namespaces = namespaces)[0].text.encode('utf-8') if node.xpath('./ns0:Resolution', namespaces = namespaces)[0].text is not None else ''
}
Thanks in advance,
Most helpful comment
Is there a chance to show the response xml? I think that I have the same problem.
In my case I was able to get the response by using history plugin.
The problem that I'm facing is that in the returned XML there are elements which are referenced by ID in the places where they should be. Probably when zeep is parsing the returned XML does not look for these references.
When I'm using suds (Jurko's fork) everything is working.