Either WSDL or wsimport and wsdl (mono) are horribly broken
Asked Answered
P

2

3

EDIT I started off with the example given below, but I have now:

  • Tried the example from the W3C spec. After fixing another error (binding was called StockQuoteSoapBinding in one place, StockQuoteBinding in another), it gives the same issue.
  • Tried the mono generator wsdl to see if wsimport was to blame. It gives an equivalent error.

So it seems to me that despite all the hype about SOAP, it doesn't actually work - at least not as advertised. I can't believe nobody has run the most findable examples of wsdl through these generators.

Original Question

wsimport is failing on the following wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="OrdersService"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:os="http://example/schema/OrdersService"
  xmlns:tns="http://example/ns/OrdersService"
  targetNamespace="http://example/ns/OrdersService"
  >

  <wsdl:types>
    <xsd:schema
      targetNamespace="http://example/schema/OrdersService">

      <xsd:element name="o:GetOrders">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="criteria" type="string"/>
      </xsd:sequence>
    </xsd:complexType>
      </xsd:element>

      <xsd:element name="os:GetOrdersResponse">
    <xsd:complexType>
      <xsd:all>
        <xsd:element name="orders" type="string"/>
      </xsd:all>
    </xsd:complexType>
      </xsd:element>

    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="GetOrdersRequest">
    <wsdl:part name="parameters" element="os:GetOrders"/>
  </wsdl:message>

  <wsdl:message name="GetOrdersResponse">
    <wsdl:part name="parameters" element="os:GetOrdersResponse"/>
  </wsdl:message>

  <wsdl:portType name="GetOrdersPortType">
    <wsdl:operation name="GetOrders">
      <wsdl:input message="tns:GetOrdersRequest"/>
      <wsdl:output message="tns:GetOrdersResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GetOrdersBinding" type="tns:GetOrdersPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetOrders">
      <soap:operation soapAction=""/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="OrdersService">
    <wsdl:port name="GetOrdersPort" binding="tns:GetOrdersBinding">
      <soap:address location="http://localhost:8080/svc/OrdersService/GetOrders"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

With:

parsing WSDL...


[ERROR] Schema descriptor {http://example/schema/OrdersService}GetOrders in message part "parameters" is not defined and could not be bound to Java. Perhaps the schema descriptor {http://example/schema/OrdersService}GetOrders is not defined in the schema imported/included in the WSDL. You can either add such imports/includes or run wsimport and provide the schema location using -b switch.
  line 35 of file:test.wsdl
Pardoner answered 5/11, 2009 at 18:11 Comment(1)
"... it doesn't actually work ..." -- I would have to agree. Every time I have to touch SOAP, I know I'm in for a programming clusterbomb. If this is the industry standard for interoperating over a wide area network, we're screwed.Steady
P
6

Although the question is rather old, here's a working WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="OrdersService"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:os="http://example/schema/OrdersService"
  xmlns:tns="http://example/ns/OrdersService"
  targetNamespace="http://example/ns/OrdersService">

  <wsdl:types>
    <xsd:schema targetNamespace="http://example/schema/OrdersService">

      <xsd:element name="GetOrders">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="criteria" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

      <xsd:element name="GetOrdersResponse">
        <xsd:complexType>
          <xsd:all>
            <xsd:element name="orders" type="xsd:string" />
          </xsd:all>
        </xsd:complexType>
      </xsd:element>

    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="GetOrdersRequest">
    <wsdl:part name="parameters" element="os:GetOrders" />
  </wsdl:message>

  <wsdl:message name="GetOrdersResponse">
    <wsdl:part name="parameters" element="os:GetOrdersResponse" />
  </wsdl:message>

  <wsdl:portType name="GetOrdersPortType">
    <wsdl:operation name="GetOrders">
      <wsdl:input message="tns:GetOrdersRequest" />
      <wsdl:output message="tns:GetOrdersResponse" />
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GetOrdersBinding" type="tns:GetOrdersPortType">
    <soap:binding style="document"
       transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetOrders">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="OrdersService">
    <wsdl:port name="GetOrdersPort" binding="tns:GetOrdersBinding">
      <soap:address
         location="http://localhost:8080/svc/OrdersService/GetOrders" />
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

Things that I've changed:

  • set xmlns:xsd to http://www.w3.org/2001/XMLSchema instead of http://www.w3.org/1999/XMLSchema (the 1999 version is quite outdated)

  • removed namespace identified from the schema elements (GetOrders instead of o:GetOrders and GetOrdersResponse instead of os:GetOrdersResponse) (namespace qualifiers are not allowed within the name attribute of an element or type definition)

  • used the correct types for the subelements criteria and orders: xsd:string instead of string


I agree, that a WSDL might be difficult in the beginning, however, once you have a grip on it, there's nothing better than a clearly defined interface. If I had a choice, I would prefer a wsdl over a json-REST-API without hesitation. But I guess that's a matter of taste ;-)

Piddle answered 3/1, 2012 at 4:14 Comment(0)
A
0

If I remember correctly, wsimport requires external namespaces to be imported in order to use elements of them in the WSDL file. In your case:

 <import namespace="http://example/schema/OrdersService"/>
Aerometeorograph answered 5/11, 2009 at 22:17 Comment(2)
Even though the schema is internal to the document (ie defined in the type section)? Thanks for the suggestion. I'll try it tomorrow.Pardoner
I now get 'missing required attribute "location" of element "wsdl:import"'. Of course the document doesn't really have a location since it's embedded.Pardoner

© 2022 - 2024 — McMap. All rights reserved.