导入 wsdl 时 svcutil 不导入错误

发布于 2024-11-06 23:58:41 字数 2058 浏览 1 评论 0原文

当从客户那里获得的 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 是从网络服务器下载的,因此我可以编辑本地副本(我用它来生成代理类)。

when generating a proxy class from a wsdl which I got from a customer, I get the following warning from 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.

So, here are the parts from the wsdl in which the ContractException is mentioned

<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>

I cannot find any problems in this wsdl, but hopefully anyone can give me a hint what I have to change so my proxy gets generated successfully.
The wsdl was donwloaded from the webserver, so I can edit my local copy (which I use for generating the proxy class).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑶笙 2024-11-13 23:58:41

根据显示的错误消息,需要将错误包装在一个元素内,即 -

而不是:

<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>

Based on the error message displayed, the fault needs to be wrapped inside an element, i.e. -

instead of:

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

you need to do this:

<wsdl:message name="ContractException">
    <wsdl:part name="fault" element="tns3:ContractException"/>
</wsdl:message>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文