On Mon September 28 2009 9:24:55 am Christian Schneider wrote:
> Hi Dan,
> 
> XmlAdapter only solves the technical problem of having classes that do
> not work well with jaxb.

Actually, it solves both problems.   If you map his Date to the normal 
Calendar, nothing about his Date gets output in the schema.   Thus, those 
details are not exposed.

Really, the XmlAdapter things are similar to a Facade, but it's on a per JAXB 
type level, not on a whole service level.  There are plusses and minuses each 
way.  If there are only a couple types that need to be done, the XmlAdapter 
stuff isn't too bad.   If you have a lot to deal with, it's not fun.

Dan



> I think the even more important problem in this case is that the
> implementation details are made visible to the service. This means that
> later changes to the implementation will
> alsways affect the service clients. So for java first I would most times
> choose a facade rather than using the XmlAdapter. The only case where I
> would omit the facade is when
> client and server are in the same release unit (what means they will
> always be updated at the same time).
> 
> Greetings
> 
> Christian
> 
> Daniel Kulp schrieb:
> > Well, with a little work, you could keep doing java first.   Basically,
> > you would need to write an XmlAdapter<Date, Calendar> (see JAXB) or
> > similar that would convert your date objects to a form that JAXB can use
> > (usually a calendar).
> >
> > Basically, if doing java first with anything complex, learning the
> > XmlAdapter things is a good idea.   Most complex things can be worked
> > around with them.
> >
> > Dan
> >
> > On Sun September 27 2009 5:20:22 pm Christian Schneider wrote:
> >> Hi Eugene,
> >>
> >> I guess you are using the Java first method of writing your service.
> >> Generally this can be problematic if you use special classes like
> >> org.joda.time.DateTime.
> >> It seems JAXB can not automatically generate a service from this class
> >> that works.
> >>
> >> If you want to stay with Java first then you should create a facade for
> >> the service that only uses classes that work for services. For example
> >> Date or Calendar for your date property.
> >>
> >> Generally it is much better to use WSDL First like in the WSDl first
> >> example. If you have trouble directly writing the WSDL you can use the
> >> method I described in:
> >> http://cxf.apache.org/docs/defining-contract-first-webservices-with-wsdl
> >>-ge neration-from-java.html
> >>
> >> Greetings
> >>
> >> Christian
> >>
> >> Eugène Stassen schrieb:
> >>> Hello,
> >>>
> >>> I have to call methods localized on a distant server. I can choose the
> >>> API for the communication. I followed a tutorial on the CXF site (
> >>> http://cxf.apache.org/docs/a-simple-jax-ws-service.html
> >>> http://cxf.apache.org/docs/a-simple-jax-ws-service.html ) and it works
> >>> very well. Unfortunately, one of my object has a member variable like
> >>> this :
> >>>
> >>> class MyObject
> >>> {
> >>>     org.joda.time.DateTime date;
> >>> }
> >>>
> >>> When I look for the xml messages, the date field is transformed to this
> >>> : "<date />". I can't find the way to do the change xml <-> java
> >>> myself. Is there an easy way to do this (for example with annotations)
> >>> ?
> >>>
> >>> I precise that I don't use Spring or other things like that, juste what
> >>> it is said in the tutorial. And I am a noob in java entreprise
> >>> applications.
> >>>
> >>> Thanks !
> >>>
> >>> Eugène Stassen
> 

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to