wsdl.exe-当Use = Literal时,标头需要element属性

wsdl.exe - The element attribute is required for headers when Use=Literal
2021-07-22
  •  译文(汉语)
  •  原文(英语)

我正在使用MS wsdl.exe从WSDL文件生成C#文件,但收到一条错误消息,说明"Use = Literal时,标头需要element属性"

我该如何摆脱呢?还有其他工具可以从wsdl生成C#吗?

    <message name="SomeHeader">
        <part name="Version" type="xsd:string"/>
    </message>

....

    <operation name="xxxxx">
        <soap:operation soapAction="xxxx"/>
        <input>
            <soap:header use="literal" message="SomeHeader" part="Version" />
            <soap:body use="literal" />
        </input>
        <output>
            <soap:body use="literal" />
        </output>
    </operation>
解决过程1

我终于解决了这个问题,将"类型"替换为"元素".

在wsdl上方修改为

<wsdl:types> 
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://tempuri.org/"
                elementFormDefault="qualified">

        <xsd:element name="Version" type="xsd:string"/>
        ....
        ....
    </xsd:schema>
</wsdl:types>


<message name="SomeHeader">
    <part name="Version" element="tns:Version"/>
</message>

I'm using MS wsdl.exe to generate C# file from a WSDL file, but get a error describes that "the element attribute is required for headers when Use=Literal"

How can I get rid of this? Is there any other tools to generate C# from wsdl?

    <message name="SomeHeader">
        <part name="Version" type="xsd:string"/>
    </message>

....

    <operation name="xxxxx">
        <soap:operation soapAction="xxxx"/>
        <input>
            <soap:header use="literal" message="SomeHeader" part="Version" />
            <soap:body use="literal" />
        </input>
        <output>
            <soap:body use="literal" />
        </output>
    </operation>
Solutions1

I finally resolved this issue by replace "type" with "element".

Modified above wsdl to

<wsdl:types> 
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://tempuri.org/"
                elementFormDefault="qualified">

        <xsd:element name="Version" type="xsd:string"/>
        ....
        ....
    </xsd:schema>
</wsdl:types>


<message name="SomeHeader">
    <part name="Version" element="tns:Version"/>
</message>
转载于:https://stackoverflow.com/questions/17362201/wsdl-exe-the-element-attribute-is-required-for-headers-when-use-literal

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入