I am using the *CXf 2.2.12* to create the dynamic webservice client, the
dynamic client is mapping the *datetime field to XMLGregorianCalendar as the
default of Jaxb* (I am using jaxb-impl and jaxb-xjc 2.1 in my classpath). I
*want it to map as java.util.Date*
Upon search, I found that we can pass the jaxb binding files to CXF client
using one of the orverloaded method createClient, but no luck.
Here is what I am doing...
List<String> bindingFiles = new ArrayList<String>();
File bindingFile = new File("C:\\test\\datebinding.xjb");
try {
bindingFiles.add(bindingFile.getCanonicalPath()toString());
} catch (IOException e) {
e.printStackTrace();
}
Client client = dcf.createClient(wsdlUrl, bindingFiles);
When I tried to generate the client using the custom binding from wsdl and
xjc tool with -b option I am able to generate the correct code (datetime
taken as java.util.Date)
xjc -wsdl -d c:/Users/pn185054/test -verbose -p com -exte
nsion -b datebinding.xjb http://localhost:8080/myWeb/ConfigServic
e?wsdl=IConfigService.wsdl
<jxb:bindings version="2.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" >
<jxb:bindings
schemaLocation="http://localhost:8080/myWeb/ConfigService?wsdl=IConfigService.wsdl"
node="/wsdl:definitions/wsdl:types/xsd:schema/xsd:complexType[@name='closeSet']/xsd:sequence/xsd:element[@name='activationDate']">
<jxb:property >
<jxb:baseType name="java.util.Date"></jxb:baseType>
</jxb:property>
</jxb:bindings>
</jxb:bindings>
with wsdl2java I used following binding file and it worked as well
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="2.0" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb">
<jxb:globalBindings>
<jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
</jxb:globalBindings>
</jxb:bindings>
Please tell me what wrong I am doing..
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-Dynamic-Client-datime-binding-tp5773287.html
Sent from the cxf-user mailing list archive at Nabble.com.