wsdl.exe错误“编码的消息部分不允许使用element属性。”

时间:2019-03-21 04:19:30

标签: c# soap wsdl wsdl.exe

我有一个要集成的SOAP服务,我想据此生成CSharp类,但是wsdl.exe和svcutil.exe都产生错误。 由于肥皂服务是由许多其他客户使用的第三方提供的,因此我无法更改它。

我看到的wsdl.exe错误是这样:

Error: The element attribute is not allowed on encoded message parts. The erroneous part is named 'return' in message 'UserLogin0Response'.

我也收到一堆或警告:

Warning: This web reference does not conform to WS-I Basic Profile v1.1.
R2706: A wsdl:binding in a DESCRIPTION MUST use the value of "literal" for the use attribute in all soapbind:body, soapbind:fault, soapbind:header and soapbind:headerfault elements.
  -  Input element soapbind:body of operation 'UserLogin' on portType 'IWsAPIUserbinding' from namespace 'http://tempuri.org'.
  -  Output element soapbind:body of operation 'UserLogin' on portType 'IWsAPIUserbinding' from namespace 'http://tempuri.org'.
  -  Input element soapbind:body of operation 'UserLogout' on portType 'IWsAPIUserbinding' from namespace 'http://tempuri.org'.
  -  Output element soapbind:body of operation 'UserLogout' on portType 'IWsAPIUserbinding' from namespace 'http://tempuri.org'.

For more details on the WS-I Basic Profile v1.1, see the specification
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html.

我以为SOAP是一个标准,所以令我惊讶的是,对于SOAP应该是什么样子,有两种相互矛盾的看法。

问题是:如何从此WSDL生成csharp类?

这是WSDL:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IWsAPIUserservice" targetNamespace="http://tempuri.org" xmlns:tns="http://tempuri.org" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
    <types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://tempuri.org">
            <xs:include schemaLocation="xsd/UserOperation.xsd"/>
        </xs:schema>
    </types>
    <message name="UserLogin0Request">
        <part name="UserName" type="xs:string"/>
        <part name="Password" type="xs:string"/>
    </message>
    <message name="UserLogin0Response">
        <part name="return" element="tns:USERLOGINRESP"/>
    </message>
    <message name="UserLogout1Request"/>
    <message name="UserLogout1Response">
        <part name="return" element="tns:USERLOGOUTRESP"/>
    </message>
    <portType name="IWsAPIUser">
        <operation name="UserLogin">
            <input message="tns:UserLogin0Request"/>
            <output message="tns:UserLogin0Response"/>
        </operation>
        <operation name="UserLogout">
            <input message="tns:UserLogout1Request"/>
            <output message="tns:UserLogout1Response"/>
        </operation>
    </portType>
    <binding name="IWsAPIUserbinding" type="tns:IWsAPIUser">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="UserLogin">
            <soap:operation soapAction="urn:WsAPIUserIntf-IWsAPIUser#UserLogin" style="rpc"/>
            <input>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WsAPIUserIntf-IWsAPIUser"/>
            </input>
            <output>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WsAPIUserIntf-IWsAPIUser"/>
            </output>
        </operation>
        <operation name="UserLogout">
            <soap:operation soapAction="urn:WsAPIUserIntf-IWsAPIUser#UserLogout" style="rpc"/>
            <input>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WsAPIUserIntf-IWsAPIUser"/>
            </input>
            <output>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WsAPIUserIntf-IWsAPIUser"/>
            </output>
        </operation>
    </binding>
    <service name="IWsAPIUserservice">
        <port name="IWsAPIUserPort" binding="tns:IWsAPIUserbinding">
            <soap:address location="https://xxxxx.xxx/IWsAPIUser"/>
        </port>
    </service>
</definitions>

0 个答案:

没有答案