You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Tamas Kis <ta...@soreco.ch> on 2010/08/17 15:13:53 UTC

Hint is needed: JAXB custom binding in CXF without Annotations

Hello Everyone,

i am loosing a lot of time with custom type binding. In fact we need to
send instances of java.lang.Number using CXF web services.

a, Java.lang.Number class cannot be extended with XmlJavaTypeAdapter
annotations.

b, We cannot add annotations to Number fields of our parameter/return
classes (of our POJO web services) either. 

c, We would like to use JAXB binding.

Consequently some global Xml - Java adapters should be added to _some_
JAXB property file. 

Could you please give some hint where is this file in CXF?? And what do
i do wrong?


I have already tried to extend some .xjb files, 
e.g. simple-binding.xjb would be:

...
<jaxb:bindings
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
  xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">

  <jaxb:bindings
schemaLocation="http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd"
node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="org.apache.cxf.wsdl"/>
        </jaxb:schemaBindings>
<!-- in a BUG archive mail i read that adapter attribute is ignored,
therefore i use parseMethod and printMethod as well here -->
  <jaxb:globalBindings generateIsSetMethod="true">
    <jaxb:javaType name="java.lang.Number" xmlType="xs:ivynumber"
adapter="ch.ivyteam.jaxb.number.NumberJaxbAdapter" 
    parseMethod="ch.ivyteam.jaxb.number.NumberJaxbAdapter.parseNumber"
    printMethod="ch.ivyteam.jaxb.number.NumberJaxbAdapter.printNumber"/>
  </jxb:globalBindings>

  </jaxb:bindings>
  <jaxb:globalBindings generateElementProperty="false">
    <xjc:simple />
  </jaxb:globalBindings>
</jaxb:bindings>


Thx in advance!
Tamas (Thomas)


Re: Hint is needed: JAXB custom binding in CXF without Annotations

Posted by Glen Mazza <gl...@gmail.com>.
Binding file example is here:
http://www.jroller.com/gmazza/entry/customizing_jaxb_artifacts#BindingFile,
see first bulletted note below it for examples on print/parse methods.

Glen


Tamas Kis wrote:
> 
> Hello Everyone,
> 
> i am loosing a lot of time with custom type binding. In fact we need to
> send instances of java.lang.Number using CXF web services.
> 
> a, Java.lang.Number class cannot be extended with XmlJavaTypeAdapter
> annotations.
> 
> b, We cannot add annotations to Number fields of our parameter/return
> classes (of our POJO web services) either. 
> 
> c, We would like to use JAXB binding.
> 
> Consequently some global Xml - Java adapters should be added to _some_
> JAXB property file. 
> 
> Could you please give some hint where is this file in CXF?? And what do
> i do wrong?
> 
> 
> I have already tried to extend some .xjb files, 
> e.g. simple-binding.xjb would be:
> 
> ...
> <jaxb:bindings
>   xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
>   xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc"
> jaxb:extensionBindingPrefixes="xjc">
> 
>   <jaxb:bindings
> schemaLocation="http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd"
> node="/xs:schema">
>         <jaxb:schemaBindings>
>             <jaxb:package name="org.apache.cxf.wsdl"/>
>         </jaxb:schemaBindings>
> <!-- in a BUG archive mail i read that adapter attribute is ignored,
> therefore i use parseMethod and printMethod as well here -->
>   <jaxb:globalBindings generateIsSetMethod="true">
>     <jaxb:javaType name="java.lang.Number" xmlType="xs:ivynumber"
> adapter="ch.ivyteam.jaxb.number.NumberJaxbAdapter" 
>     parseMethod="ch.ivyteam.jaxb.number.NumberJaxbAdapter.parseNumber"
>     printMethod="ch.ivyteam.jaxb.number.NumberJaxbAdapter.printNumber"/>
>   </jxb:globalBindings>
> 
>   </jaxb:bindings>
>   <jaxb:globalBindings generateElementProperty="false">
>     <xjc:simple />
>   </jaxb:globalBindings>
> </jaxb:bindings>
> 
> 
> Thx in advance!
> Tamas (Thomas)
> 
> 
> 

-- 
View this message in context: http://cxf.547215.n5.nabble.com/Hint-is-needed-JAXB-custom-binding-in-CXF-without-Annotations-tp2638231p2638391.html
Sent from the cxf-user mailing list archive at Nabble.com.