Python SOAP WSDL works in SOAPpy but not ZSI or zeep

五迷三道 提交于 2019-12-13 08:47:52

问题


I need a python SOAP library that can handle multipart attachments. My understanding is that this is not supported by SOAPpy or suds but that it is supported by ZSI and zeep. However, while SOAPpy works just fine with the WSDL file that I need to use, ZSI and zeep give me errors. Here is the WSDL file: http://nva1wss.webex.com/nbr/services/NBRStorageService?wsdl. I opened the file in SoapUI and used the "Check WSI Compliance" option and it passed all of the checks.

Here are my errors:

zeep.exceptions.NamespaceError: Unable to resolve type {NBRStorageService}DataHandler. No schema available for the namespace u'NBRStorageService'.

ZSI.generate.WsdlGeneratorError: failed to find import for schema "NBRStorageService"possibly missing @schemaLocation attribute.

----Updated Info----

Based on the verbose output from zeep I believe that the problem with the WSDL is that it uses a data type that zeep is unable to resolve in the schema document at http://schemas.xmlsoap.org/soap/encoding/. Here is the data type definition in the WSDL:

<wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="https://nva1wss.webex.com/nbr/services/NBRStorageService">
        <import namespace="NBRStorageService"/>
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
        <complexType name="ArrayOf_tns1_DataHandler">
            <complexContent>
                <restriction base="soapenc:Array">
                    <attribute ref="soapenc:arrayType"
                    wsdl:arrayType="tns1:DataHandler[]"/>
                </restriction>
            </complexContent>
        </complexType>
    </schema>
</wsdl:types>

This WSDL appears to have been generated with Apache Axis 1.4.

Any ideas on how to work around this? Or if anyone has any specific recommendations for server-side changes, I cannot make them, but I can certainly communicate them to the developers who handle the server.

Thank you!


回答1:


Okay. I fixed it!

So, I did some digging, and I found that this is a common problem with Axis generated WSDL’s. The DataHandler type is not supposed to be in the tns1 namespace. It is supposed to be in the apachesoap namespace. So, I changed the namespace in the WSDL, and it still did not work.

So, I did some more digging, and I found that “DataHandler is a platform-specific type that no platform other than Axis is going to understand,” and that the workaround is to change it to a type of byte.

So, here is the section of the WSDL that I have modified locally and is working now:

<wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="https://nva1wss.webex.com/nbr/services/NBRStorageService">
        <import namespace="NBRStorageService"/>
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
        <complexType name="ArrayOf_tns1_DataHandler">
            <complexContent>
                <restriction base="soapenc:Array">
                    <attribute ref="soapenc:arrayType"
                    wsdl:arrayType="soapenc:byte[]"/>
                </restriction>
            </complexContent>
        </complexType>
    </schema>
</wsdl:types>

And, BOOM! It works! I am now able to download and handle attachments as described here: http://docs.python-zeep.org/en/master/attachments.html



来源:https://stackoverflow.com/questions/45445819/python-soap-wsdl-works-in-soappy-but-not-zsi-or-zeep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!