【问题标题】:svcutil doesn't import fault when importing wsdlsvcutil 在导入 wsdl 时不导入错误
【发布时间】:2011-08-15 23:36:55
【问题描述】:

在从客户处获得的 wsdl 生成代理类时,我从 svcutil 收到以下警告:

Warning: Fault named "ContractException" in operation "create" cannot be imported.    
Unsupported WSDL, the fault message part must reference an element. This fault message    
does not reference an element. If you have edit access to the WSDL document, you can fix 
the problem by referencing a schema element using the 'element' attribute.

所以,这里是 wsdl 中提到 ContractException 的部分

<schema targetNamespace="http://exceptions.webservice"     
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://webservice" 
xmlns:intf="http://webservice"     
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
       <complexType name="ContractException">
        <sequence>
         <element name="message" nillable="true" type="xsd:string"/>
        </sequence>
       </complexType>
       <element name="ContractException" nillable="true" type="tns3:ContractException"/>
</schema>

<wsdl:message name="ContractException">
    <wsdl:part name="fault" type="tns3:ContractException"/>
</wsdl:message>

<wsdl:portType name="Contract">
    <wsdl:operation name="create" parameterOrder="pApiKey pContractData">
      <wsdl:input message="impl:createRequest" name="createRequest"/>
      <wsdl:output message="impl:createResponse" name="createResponse"/>
      <wsdl:fault message="impl:ContractException" name="ContractException"/>
    </wsdl:operation>
  </wsdl:portType>

 <wsdl:fault name="ContractException">
        <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"    
 name="ContractException" use="encoded"/>
 </wsdl:fault>

我在这个 wsdl 中找不到任何问题,但希望任何人都可以给我一个提示,我必须更改什么,以便成功生成我的代理。 wsdl 是从网络服务器下载的,因此我可以编辑本地副本(用于生成代理类)。

【问题讨论】:

    标签: wsdl svcutil.exe


    【解决方案1】:

    根据显示的错误信息,需要将故障包裹在一个元素内,即 -

    代替:

    <wsdl:message name="ContractException">
        <wsdl:part name="fault" type="tns3:ContractException"/>
    </wsdl:message>
    

    你需要这样做:

    <wsdl:message name="ContractException">
        <wsdl:part name="fault" element="tns3:ContractException"/>
    </wsdl:message>
    

    【讨论】:

      猜你喜欢
      • 2014-09-01
      • 2011-05-29
      • 1970-01-01
      • 1970-01-01
      • 2018-09-12
      • 1970-01-01
      • 2010-10-29
      • 2014-11-01
      • 2018-11-02
      相关资源
      最近更新 更多