Search code examples
xmlweb-serviceswsdl

Error creating a proxy class from a WSDL. Element missing?


I will admit I am ignorant when it comes to WSDLs. I was provided the following WSDL for a project I am working on, but it isn't working. Here is a post of the WSDL I am using. I was asked to remove the actual URL to the service from the wsdl so that it didn't get indexed and hit by crawlers. The actual URL has been replaced with 'www.testsite.org'. Here is the XML:

<wsdl:definitions xmlns:tns="https://www.testsite.org/uiws-test" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="uiicon" targetNamespace="https://www.testsite.org/uiws-test">
<!-- TYPES -->
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="https://www.testsite.org/uiws-test">
<xsd:complexType name="ResponseType">
<xsd:sequence>
<xsd:element name="request_id" type="xsd:string"/>
<xsd:element name="messages" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="responseType" type="tns:ResponseType"/>
<xsd:element name="ICON_MessageTrain" type="xsd:string"/>
<xsd:element name="fault" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<!-- MESSAGES -->
<wsdl:message name="RequestMessage">
<wsdl:part name="ICON_MessageTrain" element="tns:ICON_MessageTrain"/>
</wsdl:message>
<wsdl:message name="ResponseMessage">
<wsdl:part name="response" element="tns:responseType"/>
</wsdl:message>
<wsdl:message name="FaultMessage">
<wsdl:part name="fault" element="tns:fault"/>
</wsdl:message>
<wsdl:message name="SourceHeader">
<wsdl:part name="source" element="xsd:string"/>
</wsdl:message>
<wsdl:message name="ApplicationHeader">
<wsdl:part name="application" element="xsd:string"/>
</wsdl:message>
<!-- PORT TYPES -->
<wsdl:portType name="uiicon_portType">
<wsdl:operation name="uiicon">
<wsdl:input message="tns:RequestMessage"/>
<wsdl:output message="tns:ResponseMessage"/>
<wsdl:fault message="tns:FaultMessage" name="FaultMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- BINDINGS -->
<wsdl:binding name="uiicon_binding" type="tns:uiicon_portType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="uiicon">
<soap:operation soapAction="https://www.testsite.org/uiws-test/services/uiicon-test" style="document"/>
<wsdl:input>
<soap:header part="source" message="tns:SourceHeader" use="literal"/>
<soap:header part="application" message="tns:ApplicationHeader" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="FaultMessage">
<soap:fault name="FaultMessage" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<!-- SERVICES -->
<wsdl:service name="uiicon_service">
<wsdl:documentation>
This is the web service for UI-ICON data exchange modernization project
</wsdl:documentation>
<wsdl:port name="uiicon_port" binding="tns:uiicon_binding">
<soap:address location="https://www.testsite.org/uiws-test/services/uiicon-test"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

When I run this in wsdl.exe, I get the following error:

  • Unable to import operation 'uiicon'.
  • The element 'http://www.w3.org/2001/XMLSchema:string' is missing

I see where the wsdl is referencing the w3.org 2001 schema, and I see the string schema reference. Just not sure what it should look like and why it is wrong. Thank you!


Solution

  • The WSDL is valid if you change element to type in your SourceHeader and ApplicationHeader references, i.e.:

    <wsdl:message name="ApplicationHeader">
        <wsdl:part name="application" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="SourceHeader">
        <wsdl:part name="source" type="xsd:string"/>
    </wsdl:message>
    

    With element you reference a predefined simple or complex type. Here, however you define a new element (called application/source) that is of type xsd:string. Therefore, you need to use type.

    As far as I see, you simply want a single message part called application that contains a string. The fix should make this work and the WSDL is valid. I can't guarantee what the actual Web Service will accept/send, given its description is invalid, though...