Yukes! The Space in @WebParam

Today I really got a bite after so many years in web application coding. It is the extra space character in the @WebParam.

Problem

I had a working soap based webservice API then decided to add a new parameter to the interface. Then I started to get the following error from the service code:

Unmarshalling Error: unexpected element (uri:"", local:"author"). Expected elements are &lt;{}author >,&lt;{}isbn>,&lt;{}publishDate>,&lt;{}stockedSince>,&lt;{}title ></faultstring> 

Cause

After failing to identify the cause by closely examining the wsdl schema, double checking service deployment and decompiling the service interface, I started to play the Soap UI to shuffle the request parameter order, rename the parameters,etc. then I noticed the extra space in the fault string above. Now everything makes sense.

In the service interface, the argument is declared as “@WebParam(name = “author “) with a trailing space character copy/pasted from somewhere else. The space got removed by Jax-ws when creating WSDL document so the client side only sees “author”. When Jax-ws unmarshalling the request parameter without the trailing space, it failed to match it to the @WebParam annotated one with the trailing space.

 

Advertisements
This entry was posted in Java and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s