Skip to main content

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

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


I'm trying to call this web service:

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\ type="_moz" />

This is my hotel_info_bindings.xjb:

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


  xmlns:jaxb=&quot;; jaxb:version=&quot;2.0&quot;

  xmlns:xjc= &quot;; jaxb:extensionBindingPrefixes=&quot;xjc&quot;&gt;


    &lt;xjc:simple /&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.
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;;&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...


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