wsdl文件解析导致'无法解析类型{http://schemas.xmlsoap.org/soap/encoding/}Array。'

时间:2016-08-24 08:31:37

标签: python xml soap wsdl

首先,我不了解XML,无法确定我遇到了什么问题。我尝试使用几个python库,但大多数都导致了这个错误。 对于当前设置,我使用'zeep'python库。使用命令验证文件:

python -mzeep ss.xml

我收到此错误:

> zeep.wsdl.wsdl: Creating definition for ss.xml
zeep.wsdl.wsdl: Adding message: {urn:EngineSoap}Mailing_getStatistics
Traceback (most recent call last):
....
File "/usr/lib/python2.7/site-packages/zeep/xsd/schema.py", line 100, in get_type
) % (qname.text, qname.namespace))
KeyError: u"Unable to resolve type {http://schemas.xmlsoap.org/soap/encoding/}Array. No schema available for the namespace u'http://schemas.xmlsoap.org/soap/encoding/'."

并且xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="EngineSoap" targetNamespace="urn:EngineSoap" xmlns:typens="urn:EngineSoap" xmlns:urn="EngineSoap"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             xmlns="http://schemas.xmlsoap.org/wsdl/">
    <message name="Mailing_getStatistics">
        <part name="mailingID" type="xsd:int"/>
        <part name="periodFrom" type="xsd:string"/>
        <part name="periodTill" type="xsd:string"/>
        <part name="mlid" type="xsd:int"/>
    </message>
    <message name="Mailing_getStatisticsResponse">
        <part name="Mailing_getStatisticsReturn" type="soapenc:Array"/>
    </message>
    <message name="Mailing_getStatisticsPerLink">
        <part name="mailingID" type="xsd:int"/>
        <part name="outlink" type="xsd:boolean"/>
        <part name="mlid" type="xsd:int"/>
    </message>
    <message name="Mailing_getStatisticsPerLinkResponse">
        <part name="Mailing_getStatisticsPerLinkReturn" type="soapenc:Array"/>
    </message>

    <binding name="EngineSoapBinding" type="typens:EngineSoapPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="Mailing_getStatistics">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailing_getStatisticsPerLink">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailing_createFromContent">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailing_createFromTemplate">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailing_createFromURL">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_all">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_getUnsubscriptions">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_getUnsubscriptionsAsCSV">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_select">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_validateTechnicalSettings">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getExtraFields -->
        <operation name="Mailinglist_getExtraFields">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getSubscribersCount -->
        <operation name="Mailinglist_getSubscribersCount">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getSubscribers -->
        <operation name="Mailinglist_getSubscribers">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getSubscribersCountSince -->
        <operation name="Mailinglist_getSubscribersCountSince">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getSubscribersSince -->
        <operation name="Mailinglist_getSubscribersSince">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getStatisticsPerCampaign -->
        <operation name="Mailinglist_getStatisticsPerCampaign">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <!-- Mailinglist_getStatisticsPerSource -->
        <operation name="Mailinglist_getStatisticsPerSource">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Mailinglist_getLabels">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Customer_getBouncesForRelay">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_getByEmail">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_getByUniqueID">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_sendMailingToSubscribers">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_sendMailingToSubscribersFromCSV">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_sendMailingToSubscribersFromURL">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_sendMailingToSubscriberWithAttachment">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_set">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_unsubscribe">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_temporaryUnsubscribeByEmail">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_temporaryUnsubscribeByUniqueID">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_assignLabelWeightByEmail">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_assignLabelWeightByUniqueID">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_processLeadByEmail">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
        <operation name="Subscriber_processLeadByUniqueID">
            <soap:operation soapAction="urn:EngineSoapAction"/>
            <input>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body namespace="urn:EngineSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>

    </binding>
    <service name="EngineSoapService">
        <port name="EngineSoapPort" binding="typens:EngineSoapBinding">
            <soap:address location="http://xxxx/soap/server.live.php"/>
        </port>
    </service>
</definitions>

1 个答案:

答案 0 :(得分:1)

对于遇到相同问题的任何人(这是一个已知问题),wsdl需要导入soap编码,但不会发生。因此,请参阅代码段并在服务器的文件/响应中使用<types>声明:

<definitions targetNamespace="TARGET_NAMESPACE" ...>
    <types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="TARGET_NAMESPACE">
            <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
        </schema>
    </types>
.....
</definitions>