You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jacob Marcus <ja...@gmail.com> on 2007/08/30 16:49:06 UTC

Simple front end and JAB customization

Hi,

Is there any way to customize JAXB type mapping when using the simple front
end? I would like to have the java.util.Date for the xsd:dateTime.

Thanks,
Jacob

Re: Simple front end and JAB customization

Posted by James Mao <ja...@iona.com>.
Jacob,

Yes, It's through JAXB annotation.

First, you can find a wsdl which has the xsd:date type, then use the  
instructions in the doc to generate java artifacts from the wsdl
Then, just copy the Adapter, Annotations from those artifacts

I haven't tried this approach, but should work.

James


> James,
>
> I am using the code first (Simple front end) approach. In this case how
> would I do the jaxb customization? Is it via annotations or is there a way
> to do this in the cxf.xml file? Between, I looked at the documentation in
> detail and they seem to be related to wsdltojava tool.
>
> Thanks in advance,
> Jacob
>
> On 8/30/07, James Mao <james.mao@iona.com > wrote:
>   
>> Yes, through jaxb customization
>>
>> http://cwiki.apache.org/confluence/display/CXF20DOC/Tools
>>
>>
>> James
>>
>>
>> Jacob Marcus wrote:
>>     
>>> Hi,
>>>
>>> Is there any way to customize JAXB type mapping when using the simple
>>>       
>> front
>>     
>>> end? I would like to have the java.util.Date for the xsd:dateTime.
>>>
>>> Thanks,
>>> Jacob
>>>
>>>
>>>       
>
>   

Re: Simple front end and JAB customization

Posted by Daniel Kulp <dk...@apache.org>.
On Friday 31 August 2007, Jacob Marcus wrote:
> James,
>
> I am using the code first (Simple front end) approach. In this case
> how would I do the jaxb customization? Is it via annotations or is
> there a way to do this in the cxf.xml file? Between, I looked at the
> documentation in detail and they seem to be related to wsdltojava
> tool.

For code first, It's definitely tricky and it would only work for Date's 
held in other structures, not direct parameters/returns on the SEI 
method.   Basically, you need to write a XmlAdapter.   For Dates, it 
would look like:

package foo.date;

import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class DateAdapter
    extends XmlAdapter<String, Date> {

    public Date unmarshal(String value) {
        return 
(org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime(value));
    }

    public String marshal(Date value) {
        return 
(org.apache.cxf.tools.common.DataTypeAdapter.printDateTime(value));
    }
}

Then, you need to annotate the field in the structure to look like:

@XmlElement(name = "return", type = String.class) 
@XmlJavaTypeAdapter(DateAdapter.class)

That will tell the JAXB runtime to use the adapter to convert from the 
Date to a String.    

Dan



>
> Thanks in advance,
> Jacob
>
> On 8/30/07, James Mao <james.mao@iona.com > wrote:
> > Yes, through jaxb customization
> >
> > http://cwiki.apache.org/confluence/display/CXF20DOC/Tools
> >
> >
> > James
> >
> > Jacob Marcus wrote:
> > > Hi,
> > >
> > > Is there any way to customize JAXB type mapping when using the
> > > simple
> >
> > front
> >
> > > end? I would like to have the java.util.Date for the xsd:dateTime.
> > >
> > > Thanks,
> > > Jacob



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: Simple front end and JAB customization

Posted by Jacob Marcus <ja...@gmail.com>.
James,

I am using the code first (Simple front end) approach. In this case how
would I do the jaxb customization? Is it via annotations or is there a way
to do this in the cxf.xml file? Between, I looked at the documentation in
detail and they seem to be related to wsdltojava tool.

Thanks in advance,
Jacob

On 8/30/07, James Mao <james.mao@iona.com > wrote:
>
> Yes, through jaxb customization
>
> http://cwiki.apache.org/confluence/display/CXF20DOC/Tools
>
>
> James
>
>
> Jacob Marcus wrote:
> > Hi,
> >
> > Is there any way to customize JAXB type mapping when using the simple
> front
> > end? I would like to have the java.util.Date for the xsd:dateTime.
> >
> > Thanks,
> > Jacob
> >
> >
>

Re: Simple front end and JAB customization

Posted by James Mao <ja...@iona.com>.
Yes, through jaxb customization

http://cwiki.apache.org/confluence/display/CXF20DOC/Tools


James


Jacob Marcus wrote:
> Hi,
>
> Is there any way to customize JAXB type mapping when using the simple front
> end? I would like to have the java.util.Date for the xsd:dateTime.
>
> Thanks,
> Jacob
>
>