Tuesday, June 22, 2010

WSDLs and Message Parts not recognized

I recently ran into an interesting problem consuming a web service where a call to the service produced the following error message:

Message part {http://myservice.com/}getSets was not recognized.  (Does it exist in service WSDL?)

I originally tested the service using soapUI with no problem, but when I tried to invoke the service from elsewhere I was presented with the error.

My service WSDL was auto-generated by CXF. Here I found I had to tweak it a little to help it better conform to the doc/literal style. The message part declaration for the getSets operation originally looked something like this (nothing special):

<wsdl:message name="getSets">
<wsdl:part element="tns:getSets" name="parameters">
</wsdl:part>
</wsdl:message>

The definition of the referenced getSets element is where the problem was hiding. The element declaration contained a reference to a complexType instead of having the complexType defined within, or as part of, the element declaration.

The original element defintion:

<xs:element name="getSets" type="tns:getSets"/>
<xs:complexType name="getSets">
<xs:sequence>
<xs:element minOccurs="0" name="shipment" type="xs:string"/>
</xs:sequence>
</xs:complexType>

The new definition that allows calls from both soapUI and another client to work:

<xs:element name="getSets">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="shipment" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>

Hopefully this can help someone out who runs into something similar.

6 comments:

  1. I've had the same problem, and we use CXF as well. Can you explain what you did to "tweak it a little to help it better conform to the doc/literal style"? FWIW, I'm using the Perl module SOAP::Lite and getting the exact error message you are posting. I'd rather do that than clean up the WSDL by hand. Thanks much!

    ReplyDelete
  2. I think I had to tweak the WSDL by hand. I couldn't get the auto-generated WSDL to come out the way I describe.

    ReplyDelete
  3. i have the same problem, can you please elaborate (with steps) how to solve it?

    ReplyDelete
  4. I tried the same way but did not work

    ReplyDelete