Skip to main content

Posts

Showing posts with the label jaxb double

Problem with "double" type elements in JAXB

I have recently faced quite a lot of problem using JAXB objects to invoke SOAP webservices. There were several elements declared as : <xs:simpleType name="someAttr"><xs:restriction base="xs:double"/></xs:simpleType> When I used "wsimport" command line tool to generate Java classes for the WSDL, all those attributes generated as private double someAttr; What happened later was all the values were transformed automatically to scientific notation like : 2.85292746E8 This was a major issue, as the actual values were getting truncated.  After a long search and trial and error, I found an easy solution to my problem, to change the declaration  private double someAttr; To : private BigDecimal someAttr; No value truncation or transformation happened after that.