我正在尝试使用WCF为我公司的一个合作伙伴提供的Web服务导入WSDL.Web服务是用Java编写的.我收到此错误:
警告:无法导入操作中名为FooException的错误getUnits.不支持的WSDL,故障消息部分必须引用一个元素.此错误消息不引用元素.如果您具有对WSDL文档的编辑权限,则可以通过使用"element"属性引用schema元素来解决问题.
好吧,实际上并不是一个错误,但在生成的代码中忽略了FooException.FooException包含我真正需要的错误代码.
我缩短了WSDL,只保留了其中一种方法.我也重命名了一些东西(比如异常).
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:testws.foo.se"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:testws.foo.se"
xmlns:intf="urn:testws.foo.se"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema targetNamespace="urn:testws.foo.se" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_soapenc_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="FooException">
<sequence>
<element name="errorCode" nillable="true" type="soapenc:string"/>
<element name="errorDescription" nillable="true" type="soapenc:string"/>
<element name="variables" nillable="true" type="impl:ArrayOf_soapenc_string"/>
</sequence>
</complexType>
<element name="FooException" type="impl:FooException" nillable="true" />
<complexType name="WsUnit">
<sequence>
<element name="id" nillable="true" type="soapenc:string"/>
<element name="name" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="ArrayOfWsUnit">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="impl:WsUnit[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getUnitsRequest">
</wsdl:message>
<wsdl:message name="getUnitsResponse">
<wsdl:part name="getUnitsReturn" type="impl:ArrayOfWsUnit"/>
</wsdl:message>
<wsdl:message name="FooException">
<wsdl:part name="fault" type="impl:FooException"/>
</wsdl:message>
<wsdl:portType name="MyTest">
<wsdl:operation name="getUnits">
<wsdl:input message="impl:getUnitsRequest" name="getUnitsRequest"/>
<wsdl:output message="impl:getUnitsResponse" name="getUnitsResponse"/>
<wsdl:fault message="impl:FooException" name="FooException"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyTestSoapBinding" type="impl:MyTest">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUnits">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getUnitsRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:testws.foo.se" use="encoded"/>
</wsdl:input>
<wsdl:output name="getUnitsResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:testws.foo.se" use="encoded"/>
</wsdl:output>
<wsdl:fault name="FooException">
<wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="FooException" namespace="urn:testws.foo.se" use="encoded"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyTestService">
<wsdl:port binding="impl:MyTestSoapBinding" name="MyTest">
<wsdlsoap:address location="http://localhost:8080/axis/services/MyTest"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)
我试图在FooException的消息部分中将"type"更改为"element",但它会导致错误.我还需要做什么?