On Tuesday 19 April 2011 12:27:45 PM zahid wrote:
> Dear Experts,
>
> I am using wsld2java to generate classes from a wsdl. The wsdl has a
> reference to an xsd which defined a type as xs:double. the generated java
> code creates a double primitive. Is there a way to have the generated code
> as a java.lang.Double?
There are two options:
1) Easy - modify the wsdl to have a minOccurs=0 on the element. (or
nillible). That makes it default to Double as we'd need to be able to
represent when it's not there. That said, that does change the schema.
2) Using an external binding file. I THINK you can do something like:
<jaxws:bindings wsdlLocation="echo_date.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://date.fortest.tools.cxf.apache.org/']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:javaType name="java.lang.Double" xmlType="xs:double"/>
</jxb:globalBindings>
</jaxws:bindings>
</jaxws:bindings>
or similar to make the xs:double to the Double type. Pass the pointer to the
file to wsdl2java with the -b flag.
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com