![](/img/trans.png)
[英]Service Reference (VS2013) more than one fault is declared with element name in namespace
[英]Error when try to create Service Reference in VS2013 with fault elements from third party WSDL
我正在使用提供的用於Web服務的第三方WSDL在VS 2013中創建WCF客戶端-最有可能在Java上運行。
在原始WSDL上運行svcutil會給我一個類似於以下錯誤:
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType:
//wsdl:definitions[@targetNamespace='<ns>']/wsdl:portType[@name='xxxPort']
XPath to Error Source:
//wsdl:definitions[@targetNamespace='<ns>']/wsdl:binding[@name='xxxPortSoap11']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding:
//wsdl:definitions[@targetNamespace='<ns>']/wsdl:binding[@name='xxxPortSoap11']
XPath to Error Source:
//wsdl:definitions[@targetNamespace='<ns>']/wsdl:service[@name='xxxPortService']/wsdl:port[@name='xxxPortSoap11']
Generating files...
Warning: No code was generated. ...
為了使Service Reference正常運行(或svcutil正常運行,沒有錯誤),我必須注釋掉端口和綁定中的錯誤定義。 我可以接受這一點(因為我已經創建了一個MessageInspector
來從各種細節元素中提取錯誤),但是想要使其正常工作。
將WSDL簡化為僅顯示給我帶來問題的元素可以得出:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:tns="http://www.example.com/data/common/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:sch0="http://www.example.com/data/common/"
targetNamespace="http://www.example.com/data/common/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="http://www.example.com/data/common/"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="www.example.com/data/common/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType xmlns="http://www.w3.org/2001/XMLSchema" name="BusinessErrorType">
<xsd:sequence xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:element xmlns="http://www.w3.org/2001/XMLSchema"
name="Error" maxOccurs="unbounded" type="string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element xmlns="http://www.w3.org/2001/XMLSchema"
name="BusinessErrorFault" type="tns1:BusinessErrorType" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="BusinessErrorFault">
<wsdl:part name="BusinessErrorFault" element="sch0:BusinessErrorFault" />
</wsdl:message>
<wsdl:portType name="ViewMessagesPort">
<wsdl:operation name="BusinessError">
<wsdl:fault name="BusinessErrorFault" message="sch0:BusinessErrorFault" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ViewMessagesPortSoap11" type="sch0:ViewMessagesPort">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="BusinessError">
<soap:operation soapAction="" />
<wsdl:fault name="BusinessErrorFault">
<soap:fault use="literal" name="BusinessErrorFault" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ViewMessagesPortService">
<wsdl:port name="ViewMessagesPortSoap11" binding="sch0:ViewMessagesPortSoap11">
<soap:address location="https://www.example.com/ws/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我已經看過許多SO問題以及網上的其他地方,包括Scott Hanselman欣喜若狂地違反了規則 。
希望這是一個令人眼花obvious亂的事情……當我在英國回家的路上,我非常高興地等待池塘對面的任何答復。
UPDATE
通過https://www.wsdl-analyzer.com/傳遞上述WSDL會導致綁定錯誤:
Style: Unknown [Warn!]
Could not detect the 'use' for the operations of binding ViewMessagesPortSoap11
我還是一個聰明人。
您上面發布的WSDL存在一個問題,即沒有schema:schema:BusinessErrorFault元素期望的targetNamespace為“ http://www.example.com/data/common/ ”的架構。 我認為這可能是因為您沒有提供完整的WSDL,所以我將架構的targetNamespace更改為它。 如果此操作下一個錯誤:
<wsdl:operation name="BusinessError">
<wsdl:fault name="BusinessErrorFault" message="sch0:BusinessErrorFault" />
</wsdl:operation>
沒有輸入或輸出,只有故障,從那以后沒有故障。
我想這可能是因為您簡化了WSDL,所以如果遇到更多錯誤,請發布完整的WSDL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.