I have an element defined as xsd: double. If I try to add the value 285 to the element, and then I marshal it, I get the output 285.0 ... This is normal. However, if I put a value from 285292746, I get output 2.85292746E8 when I am marshal. I like something that double output doesn't convert to scientific decimal notation? Mostly I want 285292746 or 2852292746.0000000
java.lang.Double.toString () uses "computer scientific notation" for specific values ββthat produce isues for xml.
I know that the double representation of the setpoint is beautiful. But the fact that the value was in exponential format, the system I'm working on accepts my XML, but does not know what to do with the exponential value, and this makes my program work incorrectly. Changing xsd: double type in WSDL or server is not possible for me. I work on the client side.
I came across Jaxb: binding for xsd: double type. It is still not easy for me to fix the problem in order to send the values ββof the double value to a non-exponential format.
package com.logger.client import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.DatatypeConverter; public class JaxbDoubleSerializer extends XmlAdapter<String, Double> { public Double unmarshal(String value) { return ((double)javax.xml.bind.DatatypeConverter.parseDouble(value)); } public String marshal(Double value) { if (value == null) { return null; } return (javax.xml.bind.DatatypeConverter.printDouble((double)(double)value)); } }
I need help how to use DoubleSerializer so that I can pass values ββwithout exponents. I tried using xmlAdapter Annotation in my class MyLogClient.java. I need to know how I can solve this situation.
package com.logger.client import javax.xml.ws.BindingProvider; import javax.xml.bind.JAXBElement;import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlValue; public class MyLogClient {
}
WSDL xsd declaration: below: -
<xsd:complexType name="LogMessage"> <xsd:sequence> <xsd:element name="fileId" type="xsd:string" minOccurs="0" nillable="true" /> <xsd:element name="identifier" type="xsd:double" minOccurs="0" nillable="true" /> <xsd:element name="params" type="tns:Params" minOccurs="0" nillable="true" /> </xsd:sequence> </xsd:complexType>
Output for identifier field: -
<identifier> 2.85292746E8</indentifier> Whereas I want to send as. Because system does accept/recognize following types. <identifier> 285292746</indentifier> or <identifier> 285292746.00000000</indentifier>
user1029083
source share