开发者

Problems importing WSDL using WCF

I'm trying with WCF to import WSDL for a web service provided by one of my company's partners. The web service is written in Java. I get this error:

Warning: Fault n开发者_JAVA百科amed FooException in operation getUnits 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.

Well, not actually an error, but in the generated code FooException is ignored. FooException contains an error code which I really need.

I've shortened the WSDL and only kept one of the methods. I've also renamed some things (like the exception).

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

I've tried to just change "type" to "element" in the message part for FooException, but it results in errors. What more do I need to do?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜