You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by purushottam <pu...@gmail.com> on 2016/10/10 10:57:43 UTC

CXF Dynamic Client datime binding

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.

Re: CXF Dynamic Client datime binding

Posted by purushottam <pu...@gmail.com>.
Hi Borisov,

Thanks for your inputs.

I was using JaxWsDynamicClientFactory when I changed it to
DynamicClientFactory it started working, so with the same binding file I was
able to generate the dynamic client with datetime field mapped to java Date




--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-Dynamic-Client-datime-binding-tp5773287p5774107.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF Dynamic Client datime binding

Posted by "Vjacheslav V. Borisov" <sl...@gmail.com>.
Why do you need this in first example ?
<jxb:property >
                <jxb:baseType name="java.util.Date"></jxb:baseType>
            </jxb:property>

try  jxb:globalBindings only, without <jxb:property >


2016-10-10 14:57 GMT+04:00 purushottam <pu...@gmail.com>:

> 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
> <http://localhost:8080/myWeb/ConfigServic%0Ae?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.
>