Skip to main content

xs:int gets mapped to JAXBElement, how to map to Java int or Integer?

1 reply [Last post]
nev7n
Offline
Joined: 2011-12-21
Points: 0

Hi,

I'm trying to call this web service: http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL

The wsdl includes several elements of type 'xs:int'. These are getting mapped to 'JAXBElement<Integer>'. I've tried using the xjc:simple binding but the xs:int elements are still bound the same way.

My wsimport command line is:

 &quot;D:\Program Files\Java\jdk1.6.0_29\bin\wsimport.exe&quot; -keep -extension -B-XautoNameResolution -b hotel_info_bindings.xjb -d E:\mapov\mapov-dev\shared\hotel_info\ http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc... type="_moz" />

This is my hotel_info_bindings.xjb:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;jaxb:bindings

  xmlns:jaxb=&quot;http://java.sun.com/xml/ns/jaxb&quot; jaxb:version=&quot;2.0&quot;

  xmlns:xjc= &quot;http://java.sun.com/xml/ns/jaxb/xjc&quot; jaxb:extensionBindingPrefixes=&quot;xjc&quot;&gt;


  &lt;jaxb:globalBindings&gt;

    &lt;xjc:simple /&gt;

  &lt;/jaxb:globalBindings&gt;

&lt;/jaxb:bindings&gt;
How can I bind 'xs:int' correctly?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nev7n
Offline
Joined: 2011-12-21
Points: 0

We've tried a workaround which isn't working - creating and passing the JAXBElement using the following code:

new JAXBElement&lt;Integer&gt;(new QName(ROOT_URI, &quot;AffiliateNumber&quot;), Integer.class, value);

This generates the following XML:

&lt;ns2:AffiliateNumber xmlns:ns2=&quot;http://webservices.hotel.de/V2_8&quot;&gt;2414540&lt;/ns2:AffiliateNumber&gt;

However the webservice doesn't recognise this as valid. If I manually resend the raw request with the above XML changed to...

&lt;AffiliateNumber&gt;2414540&lt;/AffiliateNumber&gt;

...then the web service recognises this element, I can't persuade Java to send that attribute without the xmlns attribute.