You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabriel Guardincerri <gg...@gmail.com> on 2009/06/12 21:07:09 UTC

How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format

Hi, 

We have a lot of WS that were implemented using HTTP-binding of CXF 2.0.11,
but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding do
not pass params correctly. So we were trying to migrate those services to
JAX-RS. The problem is that we need to keep the same XML messages format for
backward compatibility. We tried with the three data binding providers that
are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider and
AegisElementProvider, but none of them have the same XML format for messages
that HTTP-binding has.

Is there a way to do so? I mean, to implement services with JAX-RS and use
the same XML data binding that has HTTP-binding? Or a way to build the same
XML messages?

Of course, if there is a way to make HTTP-binding work in version 2.2.2 or
2.1.5, it will be the best solution.

Thanks,

Gabriel
-- 
View this message in context: http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format-tp24004576p24004576.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
On Wed June 17 2009 12:02:15 pm Gabriel Guardincerri wrote:
> Thank you again for the fast fix!
>
> Do you know when the next release with the fix is going to be available?

Probably the week of July 20th.   Colm is planning on doing a WSS4J release 
the week of the 13th and we need to get that for some other fixes that are 
needed. 

Dan



>
> dkulp wrote:
> > On Wed June 17 2009 11:12:29 am Gabriel Guardincerri wrote:
> >> I created the jira issue and attached java code to reproduce the
> >> problem. Jira issue is CXF-2294.
> >> Do you know when you are going to be able to work on it? We need to
> >> decide
> >> what to do, and a fix for this makes a big difference.
> >
> > It's fixed on trunk.  Just merged it to 2.2.x.
> >
> > Workaround provided on the JIRA.
> >
> > Dan
> >
> >> BTW, I'm also trying to debug it to see if I find the problem.
> >>
> >> Thank you,
> >>
> >> Gabriel
> >>
> >> dkulp wrote:
> >> > On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
> >> >> Hi Daniel,
> >> >>
> >> >> I tried that patch, but I'm still getting the same error. I also
> >> >> debugged it a little bit and notice that that method is invoked only
> >> >> for PUT or POST request. But those type of requests are actually
> >> >> working for us with the new version of CXF, we don't have problems
> >> >> there. Our problem is with GET or DELETE services that have some
> >> >> parameter in the URL, like the "getUserByUsername(String username)"
> >> >> example in the files that I sent you.
> >> >>
> >> >> While debugging I also found that the method
> >> >> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
> >> >> Collection<SchemaInfo> schemas, List params)" is the one that
> >> >> is called for a GET request. And the good news is that when it is
> >> >> called it has the parameters that were in the URL and its value. I
> >> >> mean, the list "params" has for example one "Param" that is the
> >> >> username and its value when I call getUserByUsername service. So it
> >> >> seems that at that point everything is OK, and that we lose it after
> >> >> that. I was wondering if the problem is when building that document.
> >> >> Did that changed? or do you have any other ideas of where the problem
> >> >> could be?
> >> >
> >> > Nope.  Nothing on that code path seems to have changed in the http
> >> > binding.
> >> > Possibly something in the super classes someplace or the model setup
> >> > or similar.   Don't really know.   Any chance you can take your
> >> > interface (at least the affected methods) and setup a small test
> >> > project that
> >>
> >> shows
> >>
> >> > the issue and attach to a JIRA?
> >> >
> >> > Dan
> >> >
> >> >> Thank you,
> >> >>
> >> >> Gabriel
> >> >>
> >> >> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
> >> >> > Gabriel,
> >> >> >
> >> >> > Just did a diff of the http binding between 2.1.x branch and the
> >>
> >> 2.0.7
> >>
> >> >> > tag and didn't see anything obvious.   There really were not many
> >> >>
> >> >> changes
> >> >>
> >> >> > to the http binding.
> >> >> >
> >> >> > HOWEVER, I did see one suspect change.   Are you in a position to
> >> >> > be
> >> >>
> >> >> able
> >> >>
> >> >> > to patch and test?   Basically, in IriDecoderHelper.java, around
> >>
> >> line
> >>
> >> >> > 334, you should see something that looks like:
> >> >> >
> >> >> >                Node node = ec.getFirstChild();
> >> >> >                while (node != null) {
> >> >> >                    ec.removeChild(node);
> >> >> >                    node = node.getNextSibling();
> >> >> >                }
> >> >> >
> >> >> > I THINK that may be the cause of the problem.   Once the node is
> >> >>
> >> >> removed,
> >> >>
> >> >> > I'm willing to bet the node.getNextSibling() call returns null.
> >>
> >> Can
> >>
> >> >> you
> >> >>
> >> >> > try changing the code to:
> >> >> >
> >> >> >                Node node = ec.getFirstChild();
> >> >> >                while (node != null) {
> >> >> >                    Node next = node.getNextSibling();
> >> >> >                    ec.removeChild(node);
> >> >> >                    node = next;
> >> >> >                }
> >> >> >
> >> >> > and seeing if that fixes it?
> >> >> >
> >> >> > Dan
> >> >> >
> >> >> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
> >> >> >> Gabriel,
> >> >> >>
> >> >> >> Is it just the createUserWithUser message (and the PUT version)
> >>
> >> that
> >>
> >> >> is
> >> >>
> >> >> >> having the problem or are all the "Gets" also problematic?
> >> >> >>
> >> >> >> That incoming message really looks suspect.   The
> >>
> >> createUserWithUser
> >>
> >> >> >> message isn't namespace qualified at all which would be invalid
> >> >> >> per
> >> >>
> >> >> any
> >> >>
> >> >> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.
> >> >> >> Is there any way you could try a POST (with wget or something) of
> >>
> >> the
> >>
> >> >> >> message, but namespace qualify it?    I'm curious if that would
> >>
> >> work.
> >>
> >> >> >> Most likely, if you are going to want the message accepted, you'll
> >> >>
> >> >> need
> >> >>
> >> >> >> to write an interceptor that would "fake" a namespace on that
> >> >> >> element. Basically, wrapper the XMLStreamReader with a new one
> >> >> >> that would map that element name into a qualified version of it.
> >> >> >>
> >> >> >> Dan
> >> >> >>
> >> >> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> >> >> >> > Hi Dan and Sergey,
> >> >> >> >
> >> >> >> > >> The main change between them that MAY affect the XML binding
> >>
> >> is
> >>
> >> >> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code
> >>
> >> from
> >>
> >> >> xjc
> >> >>
> >> >> >> > >> can be quite different and could potentially change things.
> >> >> >> >
> >> >> >> > Dan, it may be that change. Our code works on 2.0.7, but it
> >>
> >> doesn't
> >>
> >> >> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll
> >>
> >> really
> >>
> >> >> >> > appreciate it. We want to use the latest version 2.2.2 and
> >> >> >> > JAX-RS
> >> >>
> >> >> for
> >> >>
> >> >> >> > some new web services that we need to build. But we need to keep
> >> >> >> > backward compatibility with the old web services that we have.
> >> >> >> > So
> >> >>
> >> >> the
> >> >>
> >> >> >> > best, meaning less effort, option is to have a fix for
> >>
> >> HTTP-binding
> >>
> >> >> in
> >> >>
> >> >> >> > version 2.2.2. We are planning to migrate this old services, but
> >> >> >> > not now.
> >> >> >> >
> >> >> >> > The problem is only with URL params. All our GET and DELETE
> >> >> >> > services that use some URL param don't work, they always get
> >> >> >> > null values.
> >> >> >> >
> >> >> >> > For example
> >> >> >> >
> >> >> >> > For this service
> >> >> >> >
> >> >> >> > @WebMethod
> >> >> >> > @Get
> >> >> >> > @HttpResource(location = "/users/{username}")
> >> >> >> > WSUser getUserByUsername(@WebParam(name = "username")String
> >> >>
> >> >> username)
> >> >>
> >> >> >> > throws UserNotFoundException;
> >> >> >> >
> >> >> >> > Using this request
> >> >> >> >
> >> >> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
> >> >> >> >
> >> >> >> > It doesn't work. The username param has a null value. Is there a
> >> >> >> > way to get a patch for that?
> >> >> >> >
> >> >> >> > > It is interesting. It would be helpful if Gabriel could post
> >>
> >> two
> >>
> >> >> >> > > sample XML instances, one showing what the clients are
> >>
> >> currently
> >>
> >> >> >> > > getting and what they would get if CXF 2.2.2 were used, we can
> >> >> >> > > proceed from there...
> >> >> >> >
> >> >> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get
> >>
> >> the
> >>
> >> >> >> > same XML, the problem is what I mention above, that some methods
> >> >>
> >> >> don't
> >> >>
> >> >> >> > get params. So we were thinking on migrating them to JAX-RS to
> >>
> >> make
> >>
> >> >> it
> >> >>
> >> >> >> > work, but we need to configure it to use the same XML messages
> >> >>
> >> >> format
> >> >>
> >> >> >> > that we  have for HTTP-binding. I'm attaching some xml samples
> >> >> >> > request/response and the interface with the annotations. Sorry
> >>
> >> that
> >>
> >> >> my
> >> >>
> >> >> >> > first post wasn't a clear.
> >> >> >> >
> >> >> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it
> >> >>
> >> >> work,
> >> >>
> >> >> >> > instead of migrating our old stuff. We are planning to migrate
> >>
> >> them
> >>
> >> >> >> > since it was deprecated, but if possible not for our next
> >>
> >> version,
> >>
> >> >> we
> >> >>
> >> >> >> > are short of time for this release and this problem was
> >>
> >> unexpected.
> >>
> >> >> >> > Thanks in advance,
> >> >> >> >
> >> >> >> > Gabriel
> >> >> >> >
> >> >> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
> >> >> >> > Beryozkin<sb...@progress.com>
> >> >> >>
> >> >> >> wrote:
> >> >> >> > > Hi Dan,
> >> >> >> > >
> >> >> >> > >> Sergey,
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in
> >>
> >> regards
> >>
> >> >> to
> >> >>
> >> >> >> > >> the root element things.   I'm wondering if that may have
> >> >>
> >> >> affected
> >> >>
> >> >> >> > >> this or not.
> >> >> >> > >
> >> >> >> > > possibly...
> >> >> >> > >
> >> >> >> > > thanks, Sergey
> >> >> >> > >
> >> >> >> > >> Dan
> >> >> >> > >>
> >> >> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >> >> >> > >>> Hi,
> >> >> >> > >>>
> >> >> >> > >>> As far as I'm aware no significant changes have been made to
> >> >> >> > >>> the HTTP binding recently, I haven't done any work with it
> >>
> >> for
> >>
> >> >> >> > >>> sure. Perhaps there've been some cosmetic changes but I'm
> >> >> >> > >>> not aware of them.
> >> >> >> > >>>
> >> >> >> > >>> We've agreed to deprecate the HTTP binding as all the focus
> >>
> >> now
> >>
> >> >> is
> >> >>
> >> >> >> > >>> on enhancing the JAX-RS runtime.
> >> >> >> > >>>
> >> >> >> > >>> > The problem is that we need to keep the same XML messages
> >> >>
> >> >> format
> >> >>
> >> >> >> > >>> > for
> >> >> >> > >>>
> >> >> >> > >>> backward compatibility.
> >> >> >> > >>>
> >> >> >> > >>> Can you please post a sample class annotated with
> >> >> >> > >>> HTTPBinding annotations and XML message which is expected by
> >> >> >> > >>> current clients
> >> >>
> >> >> ?
> >> >>
> >> >> >> > >>> Thanks, Sergey
> >> >> >> > >>>
> >> >> >> > >>>
> >> >> >> > >>> -----Original Message-----
> >> >> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >> >> >> > >>> Sent: 12 June 2009 20:08
> >> >> >> > >>> To: users@cxf.apache.org
> >> >> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep
> >> >> >> > >>> the xml messages format?
> >> >> >> > >>>
> >> >> >> > >>>
> >> >> >> > >>> Hi,
> >> >> >> > >>>
> >> >> >> > >>> We have a lot of WS that were implemented using HTTP-binding
> >>
> >> of
> >>
> >> >> >> > >>> CXF 2.0.11,
> >> >> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
> >> >> >> > >>> HTTP-binding do
> >> >> >> > >>> not pass params correctly. So we were trying to migrate
> >> >> >> > >>> those services to
> >> >> >> > >>> JAX-RS. The problem is that we need to keep the same XML
> >> >>
> >> >> messages
> >> >>
> >> >> >> > >>> format for
> >> >> >> > >>> backward compatibility. We tried with the three data binding
> >> >> >> > >>> providers that
> >> >> >> > >>> are in the jaxrs package XMLBeansElementProvider,
> >> >> >> > >>> JAXBElementProvider and
> >> >> >> > >>> AegisElementProvider, but none of them have the same XML
> >>
> >> format
> >>
> >> >> >> > >>> for messages
> >> >> >> > >>> that HTTP-binding has.
> >> >> >> > >>>
> >> >> >> > >>> Is there a way to do so? I mean, to implement services with
> >> >>
> >> >> JAX-RS
> >> >>
> >> >> >> > >>> and use
> >> >> >> > >>> the same XML data binding that has HTTP-binding? Or a way to
> >> >>
> >> >> build
> >> >>
> >> >> >> > >>> the same
> >> >> >> > >>> XML messages?
> >> >> >> > >>>
> >> >> >> > >>> Of course, if there is a way to make HTTP-binding work in
> >> >>
> >> >> version
> >> >>
> >> >> >> > >>> 2.2.2 or
> >> >> >> > >>> 2.1.5, it will be the best solution.
> >> >> >> > >>>
> >> >> >> > >>> Thanks,
> >> >> >> > >>>
> >> >> >> > >>> Gabriel
> >> >> >> > >>
> >> >> >> > >> --
> >> >> >> > >> Daniel Kulp
> >> >> >> > >> dkulp@apache.org
> >> >> >> > >> http://www.dankulp.com/blog
> >> >> >
> >> >> > --
> >> >> > Daniel Kulp
> >> >> > dkulp@apache.org
> >> >> > http://www.dankulp.com/blog
> >> >
> >> > --
> >> > Daniel Kulp
> >> > dkulp@apache.org
> >> > http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Thank you again for the fast fix!

Do you know when the next release with the fix is going to be available? 


dkulp wrote:
> 
> On Wed June 17 2009 11:12:29 am Gabriel Guardincerri wrote:
>> I created the jira issue and attached java code to reproduce the problem.
>> Jira issue is CXF-2294.
>> Do you know when you are going to be able to work on it? We need to
>> decide
>> what to do, and a fix for this makes a big difference.
> 
> It's fixed on trunk.  Just merged it to 2.2.x.
> 
> Workaround provided on the JIRA.
> 
> Dan
> 
> 
>>
>> BTW, I'm also trying to debug it to see if I find the problem.
>>
>> Thank you,
>>
>> Gabriel
>>
>> dkulp wrote:
>> > On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
>> >> Hi Daniel,
>> >>
>> >> I tried that patch, but I'm still getting the same error. I also
>> >> debugged it a little bit and notice that that method is invoked only
>> >> for PUT or POST request. But those type of requests are actually
>> >> working for us with the new version of CXF, we don't have problems
>> >> there. Our problem is with GET or DELETE services that have some
>> >> parameter in the URL, like the "getUserByUsername(String username)"
>> >> example in the files that I sent you.
>> >>
>> >> While debugging I also found that the method
>> >> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
>> >> Collection<SchemaInfo> schemas, List params)" is the one that
>> >> is called for a GET request. And the good news is that when it is
>> >> called it has the parameters that were in the URL and its value. I
>> >> mean, the list "params" has for example one "Param" that is the
>> >> username and its value when I call getUserByUsername service. So it
>> >> seems that at that point everything is OK, and that we lose it after
>> >> that. I was wondering if the problem is when building that document.
>> >> Did that changed? or do you have any other ideas of where the problem
>> >> could be?
>> >
>> > Nope.  Nothing on that code path seems to have changed in the http
>> > binding.
>> > Possibly something in the super classes someplace or the model setup or
>> > similar.   Don't really know.   Any chance you can take your interface
>> > (at least the affected methods) and setup a small test project that
>> shows
>> > the issue and attach to a JIRA?
>> >
>> > Dan
>> >
>> >> Thank you,
>> >>
>> >> Gabriel
>> >>
>> >> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
>> >> > Gabriel,
>> >> >
>> >> > Just did a diff of the http binding between 2.1.x branch and the
>> 2.0.7
>> >> > tag and didn't see anything obvious.   There really were not many
>> >>
>> >> changes
>> >>
>> >> > to the http binding.
>> >> >
>> >> > HOWEVER, I did see one suspect change.   Are you in a position to be
>> >>
>> >> able
>> >>
>> >> > to patch and test?   Basically, in IriDecoderHelper.java, around
>> line
>> >> > 334, you should see something that looks like:
>> >> >
>> >> >                Node node = ec.getFirstChild();
>> >> >                while (node != null) {
>> >> >                    ec.removeChild(node);
>> >> >                    node = node.getNextSibling();
>> >> >                }
>> >> >
>> >> > I THINK that may be the cause of the problem.   Once the node is
>> >>
>> >> removed,
>> >>
>> >> > I'm willing to bet the node.getNextSibling() call returns null.  
>> Can
>> >>
>> >> you
>> >>
>> >> > try changing the code to:
>> >> >
>> >> >                Node node = ec.getFirstChild();
>> >> >                while (node != null) {
>> >> >                    Node next = node.getNextSibling();
>> >> >                    ec.removeChild(node);
>> >> >                    node = next;
>> >> >                }
>> >> >
>> >> > and seeing if that fixes it?
>> >> >
>> >> > Dan
>> >> >
>> >> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
>> >> >> Gabriel,
>> >> >>
>> >> >> Is it just the createUserWithUser message (and the PUT version)
>> that
>> >>
>> >> is
>> >>
>> >> >> having the problem or are all the "Gets" also problematic?
>> >> >>
>> >> >> That incoming message really looks suspect.   The
>> createUserWithUser
>> >> >> message isn't namespace qualified at all which would be invalid per
>> >>
>> >> any
>> >>
>> >> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.    
>> >> >> Is there any way you could try a POST (with wget or something) of
>> the
>> >> >> message, but namespace qualify it?    I'm curious if that would
>> work.
>> >> >> Most likely, if you are going to want the message accepted, you'll
>> >>
>> >> need
>> >>
>> >> >> to write an interceptor that would "fake" a namespace on that
>> >> >> element. Basically, wrapper the XMLStreamReader with a new one that
>> >> >> would map that element name into a qualified version of it.
>> >> >>
>> >> >> Dan
>> >> >>
>> >> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> >> >> > Hi Dan and Sergey,
>> >> >> >
>> >> >> > >> The main change between them that MAY affect the XML binding
>> is
>> >> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code
>> from
>> >>
>> >> xjc
>> >>
>> >> >> > >> can be quite different and could potentially change things.
>> >> >> >
>> >> >> > Dan, it may be that change. Our code works on 2.0.7, but it
>> doesn't
>> >> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll
>> really
>> >> >> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS
>> >>
>> >> for
>> >>
>> >> >> > some new web services that we need to build. But we need to keep
>> >> >> > backward compatibility with the old web services that we have. So
>> >>
>> >> the
>> >>
>> >> >> > best, meaning less effort, option is to have a fix for
>> HTTP-binding
>> >>
>> >> in
>> >>
>> >> >> > version 2.2.2. We are planning to migrate this old services, but
>> >> >> > not now.
>> >> >> >
>> >> >> > The problem is only with URL params. All our GET and DELETE
>> >> >> > services that use some URL param don't work, they always get null
>> >> >> > values.
>> >> >> >
>> >> >> > For example
>> >> >> >
>> >> >> > For this service
>> >> >> >
>> >> >> > @WebMethod
>> >> >> > @Get
>> >> >> > @HttpResource(location = "/users/{username}")
>> >> >> > WSUser getUserByUsername(@WebParam(name = "username")String
>> >>
>> >> username)
>> >>
>> >> >> > throws UserNotFoundException;
>> >> >> >
>> >> >> > Using this request
>> >> >> >
>> >> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
>> >> >> >
>> >> >> > It doesn't work. The username param has a null value. Is there a
>> >> >> > way to get a patch for that?
>> >> >> >
>> >> >> > > It is interesting. It would be helpful if Gabriel could post
>> two
>> >> >> > > sample XML instances, one showing what the clients are
>> currently
>> >> >> > > getting and what they would get if CXF 2.2.2 were used, we can
>> >> >> > > proceed from there...
>> >> >> >
>> >> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get
>> the
>> >> >> > same XML, the problem is what I mention above, that some methods
>> >>
>> >> don't
>> >>
>> >> >> > get params. So we were thinking on migrating them to JAX-RS to
>> make
>> >>
>> >> it
>> >>
>> >> >> > work, but we need to configure it to use the same XML messages
>> >>
>> >> format
>> >>
>> >> >> > that we  have for HTTP-binding. I'm attaching some xml samples
>> >> >> > request/response and the interface with the annotations. Sorry
>> that
>> >>
>> >> my
>> >>
>> >> >> > first post wasn't a clear.
>> >> >> >
>> >> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it
>> >>
>> >> work,
>> >>
>> >> >> > instead of migrating our old stuff. We are planning to migrate
>> them
>> >> >> > since it was deprecated, but if possible not for our next
>> version,
>> >>
>> >> we
>> >>
>> >> >> > are short of time for this release and this problem was
>> unexpected.
>> >> >> >
>> >> >> > Thanks in advance,
>> >> >> >
>> >> >> > Gabriel
>> >> >> >
>> >> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
>> >> >> > Beryozkin<sb...@progress.com>
>> >> >>
>> >> >> wrote:
>> >> >> > > Hi Dan,
>> >> >> > >
>> >> >> > >> Sergey,
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in
>> regards
>> >>
>> >> to
>> >>
>> >> >> > >> the root element things.   I'm wondering if that may have
>> >>
>> >> affected
>> >>
>> >> >> > >> this or not.
>> >> >> > >
>> >> >> > > possibly...
>> >> >> > >
>> >> >> > > thanks, Sergey
>> >> >> > >
>> >> >> > >> Dan
>> >> >> > >>
>> >> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >> >> > >>> Hi,
>> >> >> > >>>
>> >> >> > >>> As far as I'm aware no significant changes have been made to
>> >> >> > >>> the HTTP binding recently, I haven't done any work with it
>> for
>> >> >> > >>> sure. Perhaps there've been some cosmetic changes but I'm not
>> >> >> > >>> aware of them.
>> >> >> > >>>
>> >> >> > >>> We've agreed to deprecate the HTTP binding as all the focus
>> now
>> >>
>> >> is
>> >>
>> >> >> > >>> on enhancing the JAX-RS runtime.
>> >> >> > >>>
>> >> >> > >>> > The problem is that we need to keep the same XML messages
>> >>
>> >> format
>> >>
>> >> >> > >>> > for
>> >> >> > >>>
>> >> >> > >>> backward compatibility.
>> >> >> > >>>
>> >> >> > >>> Can you please post a sample class annotated with HTTPBinding
>> >> >> > >>> annotations and XML message which is expected by current
>> >> >> > >>> clients
>> >>
>> >> ?
>> >>
>> >> >> > >>> Thanks, Sergey
>> >> >> > >>>
>> >> >> > >>>
>> >> >> > >>> -----Original Message-----
>> >> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >> >> > >>> Sent: 12 June 2009 20:08
>> >> >> > >>> To: users@cxf.apache.org
>> >> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep
>> >> >> > >>> the xml messages format?
>> >> >> > >>>
>> >> >> > >>>
>> >> >> > >>> Hi,
>> >> >> > >>>
>> >> >> > >>> We have a lot of WS that were implemented using HTTP-binding
>> of
>> >> >> > >>> CXF 2.0.11,
>> >> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >> >> > >>> HTTP-binding do
>> >> >> > >>> not pass params correctly. So we were trying to migrate those
>> >> >> > >>> services to
>> >> >> > >>> JAX-RS. The problem is that we need to keep the same XML
>> >>
>> >> messages
>> >>
>> >> >> > >>> format for
>> >> >> > >>> backward compatibility. We tried with the three data binding
>> >> >> > >>> providers that
>> >> >> > >>> are in the jaxrs package XMLBeansElementProvider,
>> >> >> > >>> JAXBElementProvider and
>> >> >> > >>> AegisElementProvider, but none of them have the same XML
>> format
>> >> >> > >>> for messages
>> >> >> > >>> that HTTP-binding has.
>> >> >> > >>>
>> >> >> > >>> Is there a way to do so? I mean, to implement services with
>> >>
>> >> JAX-RS
>> >>
>> >> >> > >>> and use
>> >> >> > >>> the same XML data binding that has HTTP-binding? Or a way to
>> >>
>> >> build
>> >>
>> >> >> > >>> the same
>> >> >> > >>> XML messages?
>> >> >> > >>>
>> >> >> > >>> Of course, if there is a way to make HTTP-binding work in
>> >>
>> >> version
>> >>
>> >> >> > >>> 2.2.2 or
>> >> >> > >>> 2.1.5, it will be the best solution.
>> >> >> > >>>
>> >> >> > >>> Thanks,
>> >> >> > >>>
>> >> >> > >>> Gabriel
>> >> >> > >>
>> >> >> > >> --
>> >> >> > >> Daniel Kulp
>> >> >> > >> dkulp@apache.org
>> >> >> > >> http://www.dankulp.com/blog
>> >> >
>> >> > --
>> >> > Daniel Kulp
>> >> > dkulp@apache.org
>> >> > http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format--tp24004576p24076807.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
On Wed June 17 2009 11:12:29 am Gabriel Guardincerri wrote:
> I created the jira issue and attached java code to reproduce the problem.
> Jira issue is CXF-2294.
> Do you know when you are going to be able to work on it? We need to decide
> what to do, and a fix for this makes a big difference.

It's fixed on trunk.  Just merged it to 2.2.x.

Workaround provided on the JIRA.

Dan


>
> BTW, I'm also trying to debug it to see if I find the problem.
>
> Thank you,
>
> Gabriel
>
> dkulp wrote:
> > On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
> >> Hi Daniel,
> >>
> >> I tried that patch, but I'm still getting the same error. I also
> >> debugged it a little bit and notice that that method is invoked only
> >> for PUT or POST request. But those type of requests are actually
> >> working for us with the new version of CXF, we don't have problems
> >> there. Our problem is with GET or DELETE services that have some
> >> parameter in the URL, like the "getUserByUsername(String username)"
> >> example in the files that I sent you.
> >>
> >> While debugging I also found that the method
> >> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
> >> Collection<SchemaInfo> schemas, List params)" is the one that
> >> is called for a GET request. And the good news is that when it is
> >> called it has the parameters that were in the URL and its value. I
> >> mean, the list "params" has for example one "Param" that is the
> >> username and its value when I call getUserByUsername service. So it
> >> seems that at that point everything is OK, and that we lose it after
> >> that. I was wondering if the problem is when building that document.
> >> Did that changed? or do you have any other ideas of where the problem
> >> could be?
> >
> > Nope.  Nothing on that code path seems to have changed in the http
> > binding.
> > Possibly something in the super classes someplace or the model setup or
> > similar.   Don't really know.   Any chance you can take your interface
> > (at least the affected methods) and setup a small test project that shows
> > the issue and attach to a JIRA?
> >
> > Dan
> >
> >> Thank you,
> >>
> >> Gabriel
> >>
> >> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
> >> > Gabriel,
> >> >
> >> > Just did a diff of the http binding between 2.1.x branch and the 2.0.7
> >> > tag and didn't see anything obvious.   There really were not many
> >>
> >> changes
> >>
> >> > to the http binding.
> >> >
> >> > HOWEVER, I did see one suspect change.   Are you in a position to be
> >>
> >> able
> >>
> >> > to patch and test?   Basically, in IriDecoderHelper.java, around line
> >> > 334, you should see something that looks like:
> >> >
> >> >                Node node = ec.getFirstChild();
> >> >                while (node != null) {
> >> >                    ec.removeChild(node);
> >> >                    node = node.getNextSibling();
> >> >                }
> >> >
> >> > I THINK that may be the cause of the problem.   Once the node is
> >>
> >> removed,
> >>
> >> > I'm willing to bet the node.getNextSibling() call returns null.   Can
> >>
> >> you
> >>
> >> > try changing the code to:
> >> >
> >> >                Node node = ec.getFirstChild();
> >> >                while (node != null) {
> >> >                    Node next = node.getNextSibling();
> >> >                    ec.removeChild(node);
> >> >                    node = next;
> >> >                }
> >> >
> >> > and seeing if that fixes it?
> >> >
> >> > Dan
> >> >
> >> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
> >> >> Gabriel,
> >> >>
> >> >> Is it just the createUserWithUser message (and the PUT version) that
> >>
> >> is
> >>
> >> >> having the problem or are all the "Gets" also problematic?
> >> >>
> >> >> That incoming message really looks suspect.   The createUserWithUser
> >> >> message isn't namespace qualified at all which would be invalid per
> >>
> >> any
> >>
> >> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.    
> >> >> Is there any way you could try a POST (with wget or something) of the
> >> >> message, but namespace qualify it?    I'm curious if that would work.
> >> >> Most likely, if you are going to want the message accepted, you'll
> >>
> >> need
> >>
> >> >> to write an interceptor that would "fake" a namespace on that
> >> >> element. Basically, wrapper the XMLStreamReader with a new one that
> >> >> would map that element name into a qualified version of it.
> >> >>
> >> >> Dan
> >> >>
> >> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> >> >> > Hi Dan and Sergey,
> >> >> >
> >> >> > >> The main change between them that MAY affect the XML binding is
> >> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code from
> >>
> >> xjc
> >>
> >> >> > >> can be quite different and could potentially change things.
> >> >> >
> >> >> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> >> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> >> >> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS
> >>
> >> for
> >>
> >> >> > some new web services that we need to build. But we need to keep
> >> >> > backward compatibility with the old web services that we have. So
> >>
> >> the
> >>
> >> >> > best, meaning less effort, option is to have a fix for HTTP-binding
> >>
> >> in
> >>
> >> >> > version 2.2.2. We are planning to migrate this old services, but
> >> >> > not now.
> >> >> >
> >> >> > The problem is only with URL params. All our GET and DELETE
> >> >> > services that use some URL param don't work, they always get null
> >> >> > values.
> >> >> >
> >> >> > For example
> >> >> >
> >> >> > For this service
> >> >> >
> >> >> > @WebMethod
> >> >> > @Get
> >> >> > @HttpResource(location = "/users/{username}")
> >> >> > WSUser getUserByUsername(@WebParam(name = "username")String
> >>
> >> username)
> >>
> >> >> > throws UserNotFoundException;
> >> >> >
> >> >> > Using this request
> >> >> >
> >> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
> >> >> >
> >> >> > It doesn't work. The username param has a null value. Is there a
> >> >> > way to get a patch for that?
> >> >> >
> >> >> > > It is interesting. It would be helpful if Gabriel could post two
> >> >> > > sample XML instances, one showing what the clients are currently
> >> >> > > getting and what they would get if CXF 2.2.2 were used, we can
> >> >> > > proceed from there...
> >> >> >
> >> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> >> >> > same XML, the problem is what I mention above, that some methods
> >>
> >> don't
> >>
> >> >> > get params. So we were thinking on migrating them to JAX-RS to make
> >>
> >> it
> >>
> >> >> > work, but we need to configure it to use the same XML messages
> >>
> >> format
> >>
> >> >> > that we  have for HTTP-binding. I'm attaching some xml samples
> >> >> > request/response and the interface with the annotations. Sorry that
> >>
> >> my
> >>
> >> >> > first post wasn't a clear.
> >> >> >
> >> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it
> >>
> >> work,
> >>
> >> >> > instead of migrating our old stuff. We are planning to migrate them
> >> >> > since it was deprecated, but if possible not for our next version,
> >>
> >> we
> >>
> >> >> > are short of time for this release and this problem was unexpected.
> >> >> >
> >> >> > Thanks in advance,
> >> >> >
> >> >> > Gabriel
> >> >> >
> >> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
> >> >> > Beryozkin<sb...@progress.com>
> >> >>
> >> >> wrote:
> >> >> > > Hi Dan,
> >> >> > >
> >> >> > >> Sergey,
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards
> >>
> >> to
> >>
> >> >> > >> the root element things.   I'm wondering if that may have
> >>
> >> affected
> >>
> >> >> > >> this or not.
> >> >> > >
> >> >> > > possibly...
> >> >> > >
> >> >> > > thanks, Sergey
> >> >> > >
> >> >> > >> Dan
> >> >> > >>
> >> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >> >> > >>> Hi,
> >> >> > >>>
> >> >> > >>> As far as I'm aware no significant changes have been made to
> >> >> > >>> the HTTP binding recently, I haven't done any work with it for
> >> >> > >>> sure. Perhaps there've been some cosmetic changes but I'm not
> >> >> > >>> aware of them.
> >> >> > >>>
> >> >> > >>> We've agreed to deprecate the HTTP binding as all the focus now
> >>
> >> is
> >>
> >> >> > >>> on enhancing the JAX-RS runtime.
> >> >> > >>>
> >> >> > >>> > The problem is that we need to keep the same XML messages
> >>
> >> format
> >>
> >> >> > >>> > for
> >> >> > >>>
> >> >> > >>> backward compatibility.
> >> >> > >>>
> >> >> > >>> Can you please post a sample class annotated with HTTPBinding
> >> >> > >>> annotations and XML message which is expected by current
> >> >> > >>> clients
> >>
> >> ?
> >>
> >> >> > >>> Thanks, Sergey
> >> >> > >>>
> >> >> > >>>
> >> >> > >>> -----Original Message-----
> >> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >> >> > >>> Sent: 12 June 2009 20:08
> >> >> > >>> To: users@cxf.apache.org
> >> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep
> >> >> > >>> the xml messages format?
> >> >> > >>>
> >> >> > >>>
> >> >> > >>> Hi,
> >> >> > >>>
> >> >> > >>> We have a lot of WS that were implemented using HTTP-binding of
> >> >> > >>> CXF 2.0.11,
> >> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
> >> >> > >>> HTTP-binding do
> >> >> > >>> not pass params correctly. So we were trying to migrate those
> >> >> > >>> services to
> >> >> > >>> JAX-RS. The problem is that we need to keep the same XML
> >>
> >> messages
> >>
> >> >> > >>> format for
> >> >> > >>> backward compatibility. We tried with the three data binding
> >> >> > >>> providers that
> >> >> > >>> are in the jaxrs package XMLBeansElementProvider,
> >> >> > >>> JAXBElementProvider and
> >> >> > >>> AegisElementProvider, but none of them have the same XML format
> >> >> > >>> for messages
> >> >> > >>> that HTTP-binding has.
> >> >> > >>>
> >> >> > >>> Is there a way to do so? I mean, to implement services with
> >>
> >> JAX-RS
> >>
> >> >> > >>> and use
> >> >> > >>> the same XML data binding that has HTTP-binding? Or a way to
> >>
> >> build
> >>
> >> >> > >>> the same
> >> >> > >>> XML messages?
> >> >> > >>>
> >> >> > >>> Of course, if there is a way to make HTTP-binding work in
> >>
> >> version
> >>
> >> >> > >>> 2.2.2 or
> >> >> > >>> 2.1.5, it will be the best solution.
> >> >> > >>>
> >> >> > >>> Thanks,
> >> >> > >>>
> >> >> > >>> Gabriel
> >> >> > >>
> >> >> > >> --
> >> >> > >> Daniel Kulp
> >> >> > >> dkulp@apache.org
> >> >> > >> http://www.dankulp.com/blog
> >> >
> >> > --
> >> > Daniel Kulp
> >> > dkulp@apache.org
> >> > http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Yeah, that is another approach...

I reckon though that some simple custom coding could do the trick too, the problem though that at the moment
Lists are not wrapped by default/automatically by JAXRS so a custom message body provider will have to be created - I need to do 
something about it to make it easier for people to migrate...

cheers, Sergey

----- Original Message ----- 
From: "Daniel Kulp" <dk...@apache.org>
To: <us...@cxf.apache.org>
Cc: "Gabriel Guardincerri" <gg...@gmail.com>
Sent: Wednesday, June 17, 2009 4:24 PM
Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?


>
> It would definitely require a "little" work to get the JAX-RS stuff to match
> the same XML.
>
> Basically, you would need to create a new JAXB bean:
>
> @XmlRootElement(name = "getUserByUsernameResponse")
> public class GetUserByNameResponse {
>    @XmlElement(name = "return")
>   User user;
>   ....
> }
>
> and change your return type in your method to that.   GetUsers would be the
> same:
>
> @XmlRootElement(name = "getUsersResponse")
> public class GetUserResponse {
>    @XmlElement(name = "return")
>   List<User> user = new ArrayList<User>();
>   ....
> }
>
> I THINK that would work.
>
> Dan
>
>
> On Wed June 17 2009 10:59:53 am Gabriel Guardincerri wrote:
>> Hi Sergey,
>>
>> Thank you for your detailed post. It seems to be really hard to have the
>> same XML format. For now, I'll wait for a patch to HTTP-binging, I'm also
>> debuging it myself trying to see if I find the problem. But we will
>> probably need to think on the alternative of breaking backward
>> compatibility and to migrate all to standard JAXRS for future releases.
>>
>> Thank you,
>>
>> Gabriel
>>
>> Sergey Beryozkin-2 wrote:
>> > Hi,
>> >
>> > I think a response like
>> >
>> > <ns1:getUserByUsernameResponse
>> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>> >   <return>
>> >     user1@fsdfsd.com
>> >     <ID>2001</ID>
>> >     <name>user1 user1</name>
>> >     <username>user1</username>
>> >   </return>
>> > </ns1:getUserByUsernameResponse>
>> >
>> > indicates that a response being formatted/wrapped according to soap
>> > rules, so it is unlikely the JAXRS runtime will be capable of formatting
>> > the same way. Now, I'm planning to support CXF Data Bindings wrapped as
>> > JAXRS message providers but I'm not sure it will help in this case.
>> >
>> > So with JAX-RS/JAXB you'll have something like
>> >
>> > <user xmlns="somenamespace">
>> >     user1@fsdfsd.com
>> >     <ID>2001</ID>
>> >     <name>user1 user1</name>
>> >     <username>user1</username>
>> > </user>
>> >
>> >
>> > I don't see what can be done at the JAXRS level to ensure that the
>> > HTTP-Binding like response is returned. You may want just to move to
>> > JAX-RS right now rather than postponing it and register an
>> > XMLStreamWriter from a JAXRS ResponseHandler filter which upon
>> > encountering a root element would replace it with a boilerplate xml like
>> >
>> > <ns1:getUserByUsernameResponse
>> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>> >   <return>
>> >
>> > and then after letting the document out finish it with
>> > </return>
>> > </ns1:getUserByUsernameResponse>
>> >
>> > I'm presuming the name of the operation is "getUserByUsername", you can
>> > get it from an input message which you can pass into your custom stax
>> > writer upon creating it in the filter.
>> >
>> > If your legacy clients were distinguishable somehow from the newer ones
>> > (say they have some unique header, etc) then you can do it for old
>> > clients only.
>> >
>> > It is just difficult for us to continue working with the HTTP Binding
>> > given that JAX-RS is a much richer spec. I'd vote for dropping it
>> > completely for 2.3 given that various new contributions are expected
>> > though still maintaining it in 2.2 fixes.
>> >
>> > Now about the list response :
>> >
>> > <ns1:getUsersResponse
>> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>> >   <return>
>> >     test@test.com
>> >     <ID>2003</ID>
>> >     <name>User Test One</name>
>> >     <username>userTest1</username>
>> >   </return>
>> >   <return>
>> >     user2@mail.com
>> >     <ID>2002</ID>
>> >     <name>user2 user2</name>
>> >     <username>user2</username>
>> >   </return>
>> > </ns1:getUsersResponse>
>> >
>> > May be we should do in JAX-RS something like
>> >
>> > <users xmlns="namespace used by user or package name derived">
>> >   <user>
>> >     test@test.com
>> >     <ID>2003</ID>
>> >     <name>User Test One</name>
>> >     <username>userTest1</username>
>> >   </user>
>> >   <user>
>> >     user2@mail.com
>> >     <ID>2002</ID>
>> >     <name>user2 user2</name>
>> >     <username>user2</username>
>> >   </user>
>> > </users>
>> >
>> > And also introduce some annotations which will give a hint to the runtime
>> > on how to customize the wrapping of the list
>> >
>> > Cheers, Sergey
>> >
>> >
>> >
>> > -----Original Message-----
>> > From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> > Sent: 16 June 2009 19:37
>> > To: users@cxf.apache.org
>> > Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> > messages format?
>> >
>> > Hi Sergey,
>> >
>> >> So what difference in formats is there when you try to switch to JAX-RS
>> >> (with JAXB 2.1 being the default provider) ? When you switch, do you
>> >> issues with all the XML samples you posted or is it with PUT only ?
>> >
>> > When I switch to JAX-RS with it's default provider I have problems
>> > with all the methods that are in the XML samples. But for PUT or POST
>> > I'm getting a java error, so it may be the qualified namespace that
>> > Daniel mention, I trying to fix and test it again.
>> >
>> > On the other side there are differences with GET requests.
>> >
>> > For the service "Get User", I get:
>> >
>> > Request:
>> >
>> > GET http://localhost:8080/rpc/rest/userService/users/user1
>> >
>> > Responses:
>> >
>> > With HTTP-binding in 2.0.x:
>> >
>> > <ns1:getUserByUsernameResponse
>> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>> >   <return>
>> >     user1@fsdfsd.com
>> >     <ID>2001</ID>
>> >     <name>user1 user1</name>
>> >     <username>user1</username>
>> >   </return>
>> > </ns1:getUserByUsernameResponse>
>> >
>> > With JAX-RS with its default provider in 2.2.2:
>> >
>> > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> > <User>
>> >     user1@fsdfsd.com
>> >     <ID>2001</ID>
>> >     <name>user1 user1</name>
>> >     <username>user1</username>
>> > </User>
>> >
>> > And for service "Get Users"
>> >
>> > Request
>> >
>> > GET http://localhost:8080/rpc/rest/userService/users
>> >
>> > Responses:
>> >
>> > With HTTP-binding in 2.0.x:
>> >
>> > <ns1:getUsersResponse
>> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>> >   <return>
>> >     test@test.com
>> >     <ID>2003</ID>
>> >     <name>User Test One</name>
>> >     <username>userTest1</username>
>> >   </return>
>> >   <return>
>> >     user2@mail.com
>> >     <ID>2002</ID>
>> >     <name>user2 user2</name>
>> >     <username>user2</username>
>> >   </return>
>> > </ns1:getUsersResponse>
>> >
>> > With JAX-RS with its default provider in 2.2.2:
>> >
>> > ".No message body writer found for response class : ArrayList."
>> >
>> >> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF
>> >> interceptors or JAX-RS filters). For ex, you can check if it's PUT and
>> >> no namespace is there and adapt as needed - let us know please if/when
>> >> you decide to go this route to make a smoother migration, we can provide
>> >> some code samples...
>> >
>> > Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
>> > they work with HTTP-binding in that version. If we couldn't find a
>> > solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
>> > this route and I'll appreciate code samples :). But for now I just
>> > prefer to see how HTTP-binding fix goes before going this way that
>> > will imply code migration and a fix to the xml messages format issue.
>> >
>> > Thank you,
>> >
>> > Gabriel
>> >
>> >> -----Original Message-----
>> >> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >> Sent: 15 June 2009 20:16
>> >> To: users@cxf.apache.org
>> >> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> >> messages format?
>> >>
>> >> Hi Dan and Sergey,
>> >>
>> >>>> The main change between them that MAY affect the XML binding is going
>> >>>> from
>> >>>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>> >>>> different and could potentially change things.
>> >>
>> >> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> >> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> >> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> >> some new web services that we need to build. But we need to keep
>> >> backward compatibility with the old web services that we have. So the
>> >> best, meaning less effort, option is to have a fix for HTTP-binding in
>> >> version 2.2.2. We are planning to migrate this old services, but not
>> >> now.
>> >>
>> >> The problem is only with URL params. All our GET and DELETE services
>> >> that use some URL param don't work, they always get null values.
>> >>
>> >> For example
>> >>
>> >> For this service
>> >>
>> >> @WebMethod
>> >> @Get
>> >> @HttpResource(location = "/users/{username}")
>> >> WSUser getUserByUsername(@WebParam(name = "username")String username)
>> >> throws UserNotFoundException;
>> >>
>> >> Using this request
>> >>
>> >> GET http://localhost:8080/rpc/rest/userService/users/user1
>> >>
>> >> It doesn't work. The username param has a null value. Is there a way
>> >> to get a patch for that?
>> >>
>> >>> It is interesting. It would be helpful if Gabriel could post two sample
>> >>> XML
>> >>> instances, one showing what the clients are currently getting and what
>> >>> they
>> >>> would get if CXF 2.2.2 were used, we can proceed from there...
>> >>
>> >> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> >> same XML, the problem is what I mention above, that some methods don't
>> >> get params. So we were thinking on migrating them to JAX-RS to make it
>> >> work, but we need to configure it to use the same XML messages format
>> >> that we  have for HTTP-binding. I'm attaching some xml samples
>> >> request/response and the interface with the annotations. Sorry that my
>> >> first post wasn't a clear.
>> >>
>> >> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> >> instead of migrating our old stuff. We are planning to migrate them
>> >> since it was deprecated, but if possible not for our next version, we
>> >> are short of time for this release and this problem was unexpected.
>> >>
>> >> Thanks in advance,
>> >>
>> >> Gabriel
>> >>
>> >> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
>> >>
>> >> wrote:
>> >>> Hi Dan,
>> >>>
>> >>>> Sergey,
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> >>>> root element things.   I'm wondering if that may have affected this or
>> >>>> not.
>> >>>
>> >>> possibly...
>> >>>
>> >>> thanks, Sergey
>> >>>
>> >>>> Dan
>> >>>>
>> >>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >>>>> Hi,
>> >>>>>
>> >>>>> As far as I'm aware no significant changes have been made to the HTTP
>> >>>>> binding recently, I haven't done any work with it for sure. Perhaps
>> >>>>> there've been some cosmetic changes but I'm not aware of them.
>> >>>>>
>> >>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>> >>>>> enhancing the JAX-RS runtime.
>> >>>>>
>> >>>>> > The problem is that we need to keep the same XML messages format
>> >>>>> > for
>> >>>>>
>> >>>>> backward compatibility.
>> >>>>>
>> >>>>> Can you please post a sample class annotated with HTTPBinding
>> >>>>> annotations and XML message which is expected by current clients ?
>> >>>>>
>> >>>>> Thanks, Sergey
>> >>>>>
>> >>>>>
>> >>>>> -----Original Message-----
>> >>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >>>>> Sent: 12 June 2009 20:08
>> >>>>> To: users@cxf.apache.org
>> >>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> >>>>> messages format?
>> >>>>>
>> >>>>>
>> >>>>> Hi,
>> >>>>>
>> >>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>> >>>>> 2.0.11,
>> >>>>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >>>>> HTTP-binding
>> >>>>> do
>> >>>>> not pass params correctly. So we were trying to migrate those
>> >>>>> services to
>> >>>>> JAX-RS. The problem is that we need to keep the same XML messages
>> >>>>> format
>> >>>>> for
>> >>>>> backward compatibility. We tried with the three data binding
>> >>>>> providers that
>> >>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>> >>>>> and
>> >>>>> AegisElementProvider, but none of them have the same XML format for
>> >>>>> messages
>> >>>>> that HTTP-binding has.
>> >>>>>
>> >>>>> Is there a way to do so? I mean, to implement services with JAX-RS
>> >>>>> and use
>> >>>>> the same XML data binding that has HTTP-binding? Or a way to build
>> >>>>> the same
>> >>>>> XML messages?
>> >>>>>
>> >>>>> Of course, if there is a way to make HTTP-binding work in version
>> >>>>> 2.2.2
>> >>>>> or
>> >>>>> 2.1.5, it will be the best solution.
>> >>>>>
>> >>>>> Thanks,
>> >>>>>
>> >>>>> Gabriel
>> >>>>
>> >>>> --
>> >>>> Daniel Kulp
>> >>>> dkulp@apache.org
>> >>>> http://www.dankulp.com/blog
>
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog 


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
It would definitely require a "little" work to get the JAX-RS stuff to match 
the same XML.   

Basically, you would need to create a new JAXB bean:

@XmlRootElement(name = "getUserByUsernameResponse")
public class GetUserByNameResponse {
    @XmlElement(name = "return")
   User user;
   ....
}

and change your return type in your method to that.   GetUsers would be the 
same:

@XmlRootElement(name = "getUsersResponse")
public class GetUserResponse {
    @XmlElement(name = "return")
   List<User> user = new ArrayList<User>();
   ....
}

I THINK that would work.

Dan


On Wed June 17 2009 10:59:53 am Gabriel Guardincerri wrote:
> Hi Sergey,
>
> Thank you for your detailed post. It seems to be really hard to have the
> same XML format. For now, I'll wait for a patch to HTTP-binging, I'm also
> debuging it myself trying to see if I find the problem. But we will
> probably need to think on the alternative of breaking backward
> compatibility and to migrate all to standard JAXRS for future releases.
>
> Thank you,
>
> Gabriel
>
> Sergey Beryozkin-2 wrote:
> > Hi,
> >
> > I think a response like
> >
> > <ns1:getUserByUsernameResponse
> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
> >   <return>
> >     user1@fsdfsd.com
> >     <ID>2001</ID>
> >     <name>user1 user1</name>
> >     <username>user1</username>
> >   </return>
> > </ns1:getUserByUsernameResponse>
> >
> > indicates that a response being formatted/wrapped according to soap
> > rules, so it is unlikely the JAXRS runtime will be capable of formatting
> > the same way. Now, I'm planning to support CXF Data Bindings wrapped as
> > JAXRS message providers but I'm not sure it will help in this case.
> >
> > So with JAX-RS/JAXB you'll have something like
> >
> > <user xmlns="somenamespace">
> >     user1@fsdfsd.com
> >     <ID>2001</ID>
> >     <name>user1 user1</name>
> >     <username>user1</username>
> > </user>
> >
> >
> > I don't see what can be done at the JAXRS level to ensure that the
> > HTTP-Binding like response is returned. You may want just to move to
> > JAX-RS right now rather than postponing it and register an
> > XMLStreamWriter from a JAXRS ResponseHandler filter which upon
> > encountering a root element would replace it with a boilerplate xml like
> >
> > <ns1:getUserByUsernameResponse
> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
> >   <return>
> >
> > and then after letting the document out finish it with
> > </return>
> > </ns1:getUserByUsernameResponse>
> >
> > I'm presuming the name of the operation is "getUserByUsername", you can
> > get it from an input message which you can pass into your custom stax
> > writer upon creating it in the filter.
> >
> > If your legacy clients were distinguishable somehow from the newer ones
> > (say they have some unique header, etc) then you can do it for old
> > clients only.
> >
> > It is just difficult for us to continue working with the HTTP Binding
> > given that JAX-RS is a much richer spec. I'd vote for dropping it
> > completely for 2.3 given that various new contributions are expected
> > though still maintaining it in 2.2 fixes.
> >
> > Now about the list response :
> >
> > <ns1:getUsersResponse
> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
> >   <return>
> >     test@test.com
> >     <ID>2003</ID>
> >     <name>User Test One</name>
> >     <username>userTest1</username>
> >   </return>
> >   <return>
> >     user2@mail.com
> >     <ID>2002</ID>
> >     <name>user2 user2</name>
> >     <username>user2</username>
> >   </return>
> > </ns1:getUsersResponse>
> >
> > May be we should do in JAX-RS something like
> >
> > <users xmlns="namespace used by user or package name derived">
> >   <user>
> >     test@test.com
> >     <ID>2003</ID>
> >     <name>User Test One</name>
> >     <username>userTest1</username>
> >   </user>
> >   <user>
> >     user2@mail.com
> >     <ID>2002</ID>
> >     <name>user2 user2</name>
> >     <username>user2</username>
> >   </user>
> > </users>
> >
> > And also introduce some annotations which will give a hint to the runtime
> > on how to customize the wrapping of the list
> >
> > Cheers, Sergey
> >
> >
> >
> > -----Original Message-----
> > From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> > Sent: 16 June 2009 19:37
> > To: users@cxf.apache.org
> > Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> > messages format?
> >
> > Hi Sergey,
> >
> >> So what difference in formats is there when you try to switch to JAX-RS
> >> (with JAXB 2.1 being the default provider) ? When you switch, do you
> >> issues with all the XML samples you posted or is it with PUT only ?
> >
> > When I switch to JAX-RS with it's default provider I have problems
> > with all the methods that are in the XML samples. But for PUT or POST
> > I'm getting a java error, so it may be the qualified namespace that
> > Daniel mention, I trying to fix and test it again.
> >
> > On the other side there are differences with GET requests.
> >
> > For the service "Get User", I get:
> >
> > Request:
> >
> > GET http://localhost:8080/rpc/rest/userService/users/user1
> >
> > Responses:
> >
> > With HTTP-binding in 2.0.x:
> >
> > <ns1:getUserByUsernameResponse
> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
> >   <return>
> >     user1@fsdfsd.com
> >     <ID>2001</ID>
> >     <name>user1 user1</name>
> >     <username>user1</username>
> >   </return>
> > </ns1:getUserByUsernameResponse>
> >
> > With JAX-RS with its default provider in 2.2.2:
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> > <User>
> >     user1@fsdfsd.com
> >     <ID>2001</ID>
> >     <name>user1 user1</name>
> >     <username>user1</username>
> > </User>
> >
> > And for service "Get Users"
> >
> > Request
> >
> > GET http://localhost:8080/rpc/rest/userService/users
> >
> > Responses:
> >
> > With HTTP-binding in 2.0.x:
> >
> > <ns1:getUsersResponse
> > xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
> >   <return>
> >     test@test.com
> >     <ID>2003</ID>
> >     <name>User Test One</name>
> >     <username>userTest1</username>
> >   </return>
> >   <return>
> >     user2@mail.com
> >     <ID>2002</ID>
> >     <name>user2 user2</name>
> >     <username>user2</username>
> >   </return>
> > </ns1:getUsersResponse>
> >
> > With JAX-RS with its default provider in 2.2.2:
> >
> > ".No message body writer found for response class : ArrayList."
> >
> >> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF
> >> interceptors or JAX-RS filters). For ex, you can check if it's PUT and
> >> no namespace is there and adapt as needed - let us know please if/when
> >> you decide to go this route to make a smoother migration, we can provide
> >> some code samples...
> >
> > Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
> > they work with HTTP-binding in that version. If we couldn't find a
> > solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
> > this route and I'll appreciate code samples :). But for now I just
> > prefer to see how HTTP-binding fix goes before going this way that
> > will imply code migration and a fix to the xml messages format issue.
> >
> > Thank you,
> >
> > Gabriel
> >
> >> -----Original Message-----
> >> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >> Sent: 15 June 2009 20:16
> >> To: users@cxf.apache.org
> >> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> >> messages format?
> >>
> >> Hi Dan and Sergey,
> >>
> >>>> The main change between them that MAY affect the XML binding is going
> >>>> from
> >>>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
> >>>> different and could potentially change things.
> >>
> >> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> >> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> >> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> >> some new web services that we need to build. But we need to keep
> >> backward compatibility with the old web services that we have. So the
> >> best, meaning less effort, option is to have a fix for HTTP-binding in
> >> version 2.2.2. We are planning to migrate this old services, but not
> >> now.
> >>
> >> The problem is only with URL params. All our GET and DELETE services
> >> that use some URL param don't work, they always get null values.
> >>
> >> For example
> >>
> >> For this service
> >>
> >> @WebMethod
> >> @Get
> >> @HttpResource(location = "/users/{username}")
> >> WSUser getUserByUsername(@WebParam(name = "username")String username)
> >> throws UserNotFoundException;
> >>
> >> Using this request
> >>
> >> GET http://localhost:8080/rpc/rest/userService/users/user1
> >>
> >> It doesn't work. The username param has a null value. Is there a way
> >> to get a patch for that?
> >>
> >>> It is interesting. It would be helpful if Gabriel could post two sample
> >>> XML
> >>> instances, one showing what the clients are currently getting and what
> >>> they
> >>> would get if CXF 2.2.2 were used, we can proceed from there...
> >>
> >> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> >> same XML, the problem is what I mention above, that some methods don't
> >> get params. So we were thinking on migrating them to JAX-RS to make it
> >> work, but we need to configure it to use the same XML messages format
> >> that we  have for HTTP-binding. I'm attaching some xml samples
> >> request/response and the interface with the annotations. Sorry that my
> >> first post wasn't a clear.
> >>
> >> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> >> instead of migrating our old stuff. We are planning to migrate them
> >> since it was deprecated, but if possible not for our next version, we
> >> are short of time for this release and this problem was unexpected.
> >>
> >> Thanks in advance,
> >>
> >> Gabriel
> >>
> >> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
> >>
> >> wrote:
> >>> Hi Dan,
> >>>
> >>>> Sergey,
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
> >>>> root element things.   I'm wondering if that may have affected this or
> >>>> not.
> >>>
> >>> possibly...
> >>>
> >>> thanks, Sergey
> >>>
> >>>> Dan
> >>>>
> >>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >>>>> Hi,
> >>>>>
> >>>>> As far as I'm aware no significant changes have been made to the HTTP
> >>>>> binding recently, I haven't done any work with it for sure. Perhaps
> >>>>> there've been some cosmetic changes but I'm not aware of them.
> >>>>>
> >>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
> >>>>> enhancing the JAX-RS runtime.
> >>>>>
> >>>>> > The problem is that we need to keep the same XML messages format
> >>>>> > for
> >>>>>
> >>>>> backward compatibility.
> >>>>>
> >>>>> Can you please post a sample class annotated with HTTPBinding
> >>>>> annotations and XML message which is expected by current clients ?
> >>>>>
> >>>>> Thanks, Sergey
> >>>>>
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >>>>> Sent: 12 June 2009 20:08
> >>>>> To: users@cxf.apache.org
> >>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> >>>>> messages format?
> >>>>>
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
> >>>>> 2.0.11,
> >>>>> but when we tried to migrate CXF to 2.2.2 we found out that
> >>>>> HTTP-binding
> >>>>> do
> >>>>> not pass params correctly. So we were trying to migrate those
> >>>>> services to
> >>>>> JAX-RS. The problem is that we need to keep the same XML messages
> >>>>> format
> >>>>> for
> >>>>> backward compatibility. We tried with the three data binding
> >>>>> providers that
> >>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
> >>>>> and
> >>>>> AegisElementProvider, but none of them have the same XML format for
> >>>>> messages
> >>>>> that HTTP-binding has.
> >>>>>
> >>>>> Is there a way to do so? I mean, to implement services with JAX-RS
> >>>>> and use
> >>>>> the same XML data binding that has HTTP-binding? Or a way to build
> >>>>> the same
> >>>>> XML messages?
> >>>>>
> >>>>> Of course, if there is a way to make HTTP-binding work in version
> >>>>> 2.2.2
> >>>>> or
> >>>>> 2.1.5, it will be the best solution.
> >>>>>
> >>>>> Thanks,
> >>>>>
> >>>>> Gabriel
> >>>>
> >>>> --
> >>>> Daniel Kulp
> >>>> dkulp@apache.org
> >>>> http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.

Should be:
<?xml version="1.0" encoding="UTF-8"?> 
<ns1:createUserWithUser 
xmlns:ns1="http://jivesoftware.com/clearspace/webservices"> 
  <user> 
    <username>userTest1</username> 
    <name>User Test One</name> 
    <email>test@...</email> 
    <password>secret</password> 
  </user> 
</ns1:createUserWithUser> 


But if those methods are working for you, then probably not a big deal either 
way.
Dan


On Tue June 16 2009 1:51:57 pm Gabriel Guardincerri wrote:
> Hi Daniel,
>
> Could you give an example of a qualified namespace for this?
>
> Thanks,
>
> Gabriel
>
> dkulp wrote:
> > Gabriel,
> >
> > Is it just the createUserWithUser message (and the PUT version) that is
> > having
> > the problem or are all the "Gets" also problematic?
> >
> > That incoming message really looks suspect.   The createUserWithUser
> > message
> > isn't namespace qualified at all which would be invalid per any of the
> > schema.
> > Thus, I'm surprised that even worked with 2.0.x.     Is there any way you
> > could try a POST (with wget or something) of the message, but namespace
> > qualify it?    I'm curious if that would work.    Most likely, if you are
> > going to want the message accepted, you'll need to write an interceptor
> > that
> > would "fake" a namespace on that element.   Basically, wrapper the
> > XMLStreamReader with a new one that would map that element name into a
> > qualified version of it.
> >
> > Dan
> >
> > On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> >> Hi Dan and Sergey,
> >>
> >> >> The main change between them that MAY affect the XML binding is going
> >> >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
> >> >> quite different and could potentially change things.
> >>
> >> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> >> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> >> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> >> some new web services that we need to build. But we need to keep
> >> backward compatibility with the old web services that we have. So the
> >> best, meaning less effort, option is to have a fix for HTTP-binding in
> >> version 2.2.2. We are planning to migrate this old services, but not
> >> now.
> >>
> >> The problem is only with URL params. All our GET and DELETE services
> >> that use some URL param don't work, they always get null values.
> >>
> >> For example
> >>
> >> For this service
> >>
> >> @WebMethod
> >> @Get
> >> @HttpResource(location = "/users/{username}")
> >> WSUser getUserByUsername(@WebParam(name = "username")String username)
> >> throws UserNotFoundException;
> >>
> >> Using this request
> >>
> >> GET http://localhost:8080/rpc/rest/userService/users/user1
> >>
> >> It doesn't work. The username param has a null value. Is there a way
> >> to get a patch for that?
> >>
> >> > It is interesting. It would be helpful if Gabriel could post two
> >> > sample XML instances, one showing what the clients are currently
> >> > getting and what they would get if CXF 2.2.2 were used, we can proceed
> >> > from
> >>
> >> there...
> >>
> >> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> >> same XML, the problem is what I mention above, that some methods don't
> >> get params. So we were thinking on migrating them to JAX-RS to make it
> >> work, but we need to configure it to use the same XML messages format
> >> that we  have for HTTP-binding. I'm attaching some xml samples
> >> request/response and the interface with the annotations. Sorry that my
> >> first post wasn't a clear.
> >>
> >> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> >> instead of migrating our old stuff. We are planning to migrate them
> >> since it was deprecated, but if possible not for our next version, we
> >> are short of time for this release and this problem was unexpected.
> >>
> >> Thanks in advance,
> >>
> >> Gabriel
> >>
> >> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
> >
> > wrote:
> >> > Hi Dan,
> >> >
> >> >> Sergey,
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to
> >> >> the root element things.   I'm wondering if that may have affected
> >> >> this or not.
> >> >
> >> > possibly...
> >> >
> >> > thanks, Sergey
> >> >
> >> >> Dan
> >> >>
> >> >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >> >>> Hi,
> >> >>>
> >> >>> As far as I'm aware no significant changes have been made to the
> >> >>> HTTP binding recently, I haven't done any work with it for sure.
> >> >>> Perhaps there've been some cosmetic changes but I'm not aware of
> >> >>> them.
> >> >>>
> >> >>> We've agreed to deprecate the HTTP binding as all the focus now is
> >> >>> on enhancing the JAX-RS runtime.
> >> >>>
> >> >>> > The problem is that we need to keep the same XML messages format
> >>
> >> for
> >>
> >> >>> backward compatibility.
> >> >>>
> >> >>> Can you please post a sample class annotated with HTTPBinding
> >> >>> annotations and XML message which is expected by current clients ?
> >> >>>
> >> >>> Thanks, Sergey
> >> >>>
> >> >>>
> >> >>> -----Original Message-----
> >> >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >> >>> Sent: 12 June 2009 20:08
> >> >>> To: users@cxf.apache.org
> >> >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> >> >>> messages format?
> >> >>>
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> We have a lot of WS that were implemented using HTTP-binding of CXF
> >> >>> 2.0.11,
> >> >>> but when we tried to migrate CXF to 2.2.2 we found out that
> >> >>> HTTP-binding do
> >> >>> not pass params correctly. So we were trying to migrate those
> >>
> >> services
> >>
> >> >>> to
> >> >>> JAX-RS. The problem is that we need to keep the same XML messages
> >> >>> format for
> >> >>> backward compatibility. We tried with the three data binding
> >>
> >> providers
> >>
> >> >>> that
> >> >>> are in the jaxrs package XMLBeansElementProvider,
> >> >>> JAXBElementProvider and
> >> >>> AegisElementProvider, but none of them have the same XML format for
> >> >>> messages
> >> >>> that HTTP-binding has.
> >> >>>
> >> >>> Is there a way to do so? I mean, to implement services with JAX-RS
> >>
> >> and
> >>
> >> >>> use
> >> >>> the same XML data binding that has HTTP-binding? Or a way to build
> >>
> >> the
> >>
> >> >>> same
> >> >>> XML messages?
> >> >>>
> >> >>> Of course, if there is a way to make HTTP-binding work in version
> >>
> >> 2.2.2
> >>
> >> >>> or
> >> >>> 2.1.5, it will be the best solution.
> >> >>>
> >> >>> Thanks,
> >> >>>
> >> >>> Gabriel
> >> >>
> >> >> --
> >> >> Daniel Kulp
> >> >> dkulp@apache.org
> >> >> http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

RE: Few Open issues using UserName Token Profile

Posted by bharath thippireddy <bh...@oracle.com>.
Hi Mayank,

Thanks for the details.To give you a few more details on the 2nd question below.

1) Once we enable the ws-security and start using the actions like below .
 
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
	         <constructor-arg>
	            <map>
	               <entry key="action" value="UsernameToken Encrypt"/>


And if the client doesn't send a user name token and uses some other login mechanism say cookies we see the 

org.apache.ws.security.WSSecurityException: An error was discovered processing the <wsse:Security> header
        at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:200)

How can we make the options optional?

2)You have mentioned that CXF has the nonce support if we use password digest .But the cxf documentation says that cxf doesn't have the implementation for nonce.Can you point me to some docs which show how it works on the server side.I think  that cxf does have the client side support,but not the server side caching/processing nonces.

http://cwiki.apache.org/CXF20DOC/ws-security.html

Thanks and regards,
Bharath


-----Original Message-----
From: Mayank Mishra [mailto:mayankm01@gmail.com] 
Sent: Wednesday, June 17, 2009 2:46 PM
To: users@cxf.apache.org
Subject: Re: Few Open issues using UserName Token Profile

bharath thippireddy wrote:
> 1)How do we configure the interceptors at a bus level in cxf-servlet.xml along with the endpoint declarations.
>
>
Configuring the CXF Bus can be found at [1]
> 2)Once the ws-security(user name token profile/encryption) is enabled on each endpoint using the declarative method in cxf-servlet.xml we see the following exception if the client sends a request without user token soap header.Since we will be having other methods to authenticate how can we make these headers optional. Is commenting the ws-security interceptor declaration in the cxf-servlet.xml the only way?
>
>
If I am able to understand this point, you want to allow some client
request which doesn't have user name tokens. If this is the requirement
you can make use of WS-Policy to specify an optional behavior of
WS-SecurityPolicy.
or if in case you want to process the authentication yourself you can
write the custom authentication mechanism in CallbackHandler
or if in case you are sending your own custom user name token in the
header then you can write your own Interceptor to handle the DOM
presented by SAAJ.
> Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
> WARNING: Request does not contain required Security header
> Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
> WARNING:
> org.apache.ws.security.WSSecurityException: An error was discovered processing the <wsse:Security> header
>         at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:200)
>         at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:77)
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
>         at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
>         at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
>         at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:337)
>         at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:182)
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:141)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> 3)Does cxf support having custom tokens under the username token header ?.I do see the methods available on the client and server callback classes but I do not see the custom element getting added to the UT header.
>
>         Document doc = docBuilder.newDocument();
>         Element customToken=doc.createElement("customToken");
>         dbId.setTextContent("1");
> 		pc.setCustomToken(customToken);
>
>
>
I never came across custom  tokens under username token in UsernameToken
specification (both 1.0 and 1.1) by OASIS. Upto my best information
there's nothing like that. Will be a surprise to me too :)

With Regards,
Mayank

[1]. http://cwiki.apache.org/CXF20DOC/bus-configuration.html
> thanks and regards,
> Bharath
>
>
>



Re: Few Open issues using UserName Token Profile

Posted by Mayank Mishra <ma...@gmail.com>.
bharath thippireddy wrote:
> 1)How do we configure the interceptors at a bus level in cxf-servlet.xml along with the endpoint declarations.
>
>   
Configuring the CXF Bus can be found at [1]
> 2)Once the ws-security(user name token profile/encryption) is enabled on each endpoint using the declarative method in cxf-servlet.xml we see the following exception if the client sends a request without user token soap header.Since we will be having other methods to authenticate how can we make these headers optional. Is commenting the ws-security interceptor declaration in the cxf-servlet.xml the only way?
>
>   
If I am able to understand this point, you want to allow some client 
request which doesn't have user name tokens. If this is the requirement 
you can make use of WS-Policy to specify an optional behavior of 
WS-SecurityPolicy.
or if in case you want to process the authentication yourself you can 
write the custom authentication mechanism in CallbackHandler
or if in case you are sending your own custom user name token in the 
header then you can write your own Interceptor to handle the DOM 
presented by SAAJ.
> Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
> WARNING: Request does not contain required Security header
> Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
> WARNING:
> org.apache.ws.security.WSSecurityException: An error was discovered processing the <wsse:Security> header
>         at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:200)
>         at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:77)
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
>         at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
>         at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
>         at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:337)
>         at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:182)
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:141)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> 3)Does cxf support having custom tokens under the username token header ?.I do see the methods available on the client and server callback classes but I do not see the custom element getting added to the UT header.
>
>         Document doc = docBuilder.newDocument();
>         Element customToken=doc.createElement("customToken");
>         dbId.setTextContent("1");
> 		pc.setCustomToken(customToken);
>
>
>   
I never came across custom  tokens under username token in UsernameToken 
specification (both 1.0 and 1.1) by OASIS. Upto my best information 
there's nothing like that. Will be a surprise to me too :)

With Regards,
Mayank

[1]. http://cwiki.apache.org/CXF20DOC/bus-configuration.html
> thanks and regards,
> Bharath
>
>
>   


Few Open issues using UserName Token Profile

Posted by bharath thippireddy <bh...@oracle.com>.
1)How do we configure the interceptors at a bus level in cxf-servlet.xml along with the endpoint declarations.

2)Once the ws-security(user name token profile/encryption) is enabled on each endpoint using the declarative method in cxf-servlet.xml we see the following exception if the client sends a request without user token soap header.Since we will be having other methods to authenticate how can we make these headers optional. Is commenting the ws-security interceptor declaration in the cxf-servlet.xml the only way?

Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
WARNING: Request does not contain required Security header
Jun 16, 2009 1:43:28 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage
WARNING:
org.apache.ws.security.WSSecurityException: An error was discovered processing the <wsse:Security> header
        at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:200)
        at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:77)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:337)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:182)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:141)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

3)Does cxf support having custom tokens under the username token header ?.I do see the methods available on the client and server callback classes but I do not see the custom element getting added to the UT header.

        Document doc = docBuilder.newDocument();
        Element customToken=doc.createElement("customToken");
        dbId.setTextContent("1");
		pc.setCustomToken(customToken);



thanks and regards,
Bharath


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Sure, I'll build that example, thank you!

On Tue, Jun 16, 2009 at 3:08 PM, Daniel Kulp<dk...@apache.org> wrote:
> On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
>> Hi Daniel,
>>
>> I tried that patch, but I'm still getting the same error. I also
>> debugged it a little bit and notice that that method is invoked only
>> for PUT or POST request. But those type of requests are actually
>> working for us with the new version of CXF, we don't have problems
>> there. Our problem is with GET or DELETE services that have some
>> parameter in the URL, like the "getUserByUsername(String username)"
>> example in the files that I sent you.
>>
>> While debugging I also found that the method
>> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
>> Collection<SchemaInfo> schemas, List<Param> params)" is the one that
>> is called for a GET request. And the good news is that when it is
>> called it has the parameters that were in the URL and its value. I
>> mean, the list "params" has for example one "Param" that is the
>> username and its value when I call getUserByUsername service. So it
>> seems that at that point everything is OK, and that we lose it after
>> that. I was wondering if the problem is when building that document.
>> Did that changed? or do you have any other ideas of where the problem
>> could be?
>
> Nope.  Nothing on that code path seems to have changed in the http binding.
> Possibly something in the super classes someplace or the model setup or
> similar.   Don't really know.   Any chance you can take your interface (at
> least the affected methods) and setup a small test project that shows the
> issue and attach to a JIRA?
>
> Dan
>
>
>
>> Thank you,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
>> > Gabriel,
>> >
>> > Just did a diff of the http binding between 2.1.x branch and the 2.0.7
>> > tag and didn't see anything obvious.   There really were not many changes
>> > to the http binding.
>> >
>> > HOWEVER, I did see one suspect change.   Are you in a position to be able
>> > to patch and test?   Basically, in IriDecoderHelper.java, around line
>> > 334, you should see something that looks like:
>> >
>> >                Node node = ec.getFirstChild();
>> >                while (node != null) {
>> >                    ec.removeChild(node);
>> >                    node = node.getNextSibling();
>> >                }
>> >
>> > I THINK that may be the cause of the problem.   Once the node is removed,
>> > I'm willing to bet the node.getNextSibling() call returns null.   Can you
>> > try changing the code to:
>> >
>> >                Node node = ec.getFirstChild();
>> >                while (node != null) {
>> >                    Node next = node.getNextSibling();
>> >                    ec.removeChild(node);
>> >                    node = next;
>> >                }
>> >
>> > and seeing if that fixes it?
>> >
>> > Dan
>> >
>> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
>> >> Gabriel,
>> >>
>> >> Is it just the createUserWithUser message (and the PUT version) that is
>> >> having the problem or are all the "Gets" also problematic?
>> >>
>> >> That incoming message really looks suspect.   The createUserWithUser
>> >> message isn't namespace qualified at all which would be invalid per any
>> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.     Is
>> >> there any way you could try a POST (with wget or something) of the
>> >> message, but namespace qualify it?    I'm curious if that would work.
>> >>  Most likely, if you are going to want the message accepted, you'll need
>> >> to write an interceptor that would "fake" a namespace on that element.
>> >> Basically, wrapper the XMLStreamReader with a new one that would map
>> >> that element name into a qualified version of it.
>> >>
>> >> Dan
>> >>
>> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> >> > Hi Dan and Sergey,
>> >> >
>> >> > >> The main change between them that MAY affect the XML binding is
>> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc
>> >> > >> can be quite different and could potentially change things.
>> >> >
>> >> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> >> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> >> > some new web services that we need to build. But we need to keep
>> >> > backward compatibility with the old web services that we have. So the
>> >> > best, meaning less effort, option is to have a fix for HTTP-binding in
>> >> > version 2.2.2. We are planning to migrate this old services, but not
>> >> > now.
>> >> >
>> >> > The problem is only with URL params. All our GET and DELETE services
>> >> > that use some URL param don't work, they always get null values.
>> >> >
>> >> > For example
>> >> >
>> >> > For this service
>> >> >
>> >> > @WebMethod
>> >> > @Get
>> >> > @HttpResource(location = "/users/{username}")
>> >> > WSUser getUserByUsername(@WebParam(name = "username")String username)
>> >> > throws UserNotFoundException;
>> >> >
>> >> > Using this request
>> >> >
>> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
>> >> >
>> >> > It doesn't work. The username param has a null value. Is there a way
>> >> > to get a patch for that?
>> >> >
>> >> > > It is interesting. It would be helpful if Gabriel could post two
>> >> > > sample XML instances, one showing what the clients are currently
>> >> > > getting and what they would get if CXF 2.2.2 were used, we can
>> >> > > proceed from there...
>> >> >
>> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> >> > same XML, the problem is what I mention above, that some methods don't
>> >> > get params. So we were thinking on migrating them to JAX-RS to make it
>> >> > work, but we need to configure it to use the same XML messages format
>> >> > that we  have for HTTP-binding. I'm attaching some xml samples
>> >> > request/response and the interface with the annotations. Sorry that my
>> >> > first post wasn't a clear.
>> >> >
>> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> >> > instead of migrating our old stuff. We are planning to migrate them
>> >> > since it was deprecated, but if possible not for our next version, we
>> >> > are short of time for this release and this problem was unexpected.
>> >> >
>> >> > Thanks in advance,
>> >> >
>> >> > Gabriel
>> >> >
>> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
>> >> > Beryozkin<sb...@progress.com>
>> >>
>> >> wrote:
>> >> > > Hi Dan,
>> >> > >
>> >> > >> Sergey,
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to
>> >> > >> the root element things.   I'm wondering if that may have affected
>> >> > >> this or not.
>> >> > >
>> >> > > possibly...
>> >> > >
>> >> > > thanks, Sergey
>> >> > >
>> >> > >> Dan
>> >> > >>
>> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >> > >>> Hi,
>> >> > >>>
>> >> > >>> As far as I'm aware no significant changes have been made to the
>> >> > >>> HTTP binding recently, I haven't done any work with it for sure.
>> >> > >>> Perhaps there've been some cosmetic changes but I'm not aware of
>> >> > >>> them.
>> >> > >>>
>> >> > >>> We've agreed to deprecate the HTTP binding as all the focus now is
>> >> > >>> on enhancing the JAX-RS runtime.
>> >> > >>>
>> >> > >>> > The problem is that we need to keep the same XML messages format
>> >> > >>> > for
>> >> > >>>
>> >> > >>> backward compatibility.
>> >> > >>>
>> >> > >>> Can you please post a sample class annotated with HTTPBinding
>> >> > >>> annotations and XML message which is expected by current clients ?
>> >> > >>>
>> >> > >>> Thanks, Sergey
>> >> > >>>
>> >> > >>>
>> >> > >>> -----Original Message-----
>> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >> > >>> Sent: 12 June 2009 20:08
>> >> > >>> To: users@cxf.apache.org
>> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the
>> >> > >>> xml messages format?
>> >> > >>>
>> >> > >>>
>> >> > >>> Hi,
>> >> > >>>
>> >> > >>> We have a lot of WS that were implemented using HTTP-binding of
>> >> > >>> CXF 2.0.11,
>> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >> > >>> HTTP-binding do
>> >> > >>> not pass params correctly. So we were trying to migrate those
>> >> > >>> services to
>> >> > >>> JAX-RS. The problem is that we need to keep the same XML messages
>> >> > >>> format for
>> >> > >>> backward compatibility. We tried with the three data binding
>> >> > >>> providers that
>> >> > >>> are in the jaxrs package XMLBeansElementProvider,
>> >> > >>> JAXBElementProvider and
>> >> > >>> AegisElementProvider, but none of them have the same XML format
>> >> > >>> for messages
>> >> > >>> that HTTP-binding has.
>> >> > >>>
>> >> > >>> Is there a way to do so? I mean, to implement services with JAX-RS
>> >> > >>> and use
>> >> > >>> the same XML data binding that has HTTP-binding? Or a way to build
>> >> > >>> the same
>> >> > >>> XML messages?
>> >> > >>>
>> >> > >>> Of course, if there is a way to make HTTP-binding work in version
>> >> > >>> 2.2.2 or
>> >> > >>> 2.1.5, it will be the best solution.
>> >> > >>>
>> >> > >>> Thanks,
>> >> > >>>
>> >> > >>> Gabriel
>> >> > >>
>> >> > >> --
>> >> > >> Daniel Kulp
>> >> > >> dkulp@apache.org
>> >> > >> http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
I created the jira issue and attached java code to reproduce the problem.
Jira issue is CXF-2294.
Do you know when you are going to be able to work on it? We need to decide
what to do, and a fix for this makes a big difference. 

BTW, I'm also trying to debug it to see if I find the problem.

Thank you,

Gabriel


dkulp wrote:
> 
> On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
>> Hi Daniel,
>>
>> I tried that patch, but I'm still getting the same error. I also
>> debugged it a little bit and notice that that method is invoked only
>> for PUT or POST request. But those type of requests are actually
>> working for us with the new version of CXF, we don't have problems
>> there. Our problem is with GET or DELETE services that have some
>> parameter in the URL, like the "getUserByUsername(String username)"
>> example in the files that I sent you.
>>
>> While debugging I also found that the method
>> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
>> Collection<SchemaInfo> schemas, List params)" is the one that
>> is called for a GET request. And the good news is that when it is
>> called it has the parameters that were in the URL and its value. I
>> mean, the list "params" has for example one "Param" that is the
>> username and its value when I call getUserByUsername service. So it
>> seems that at that point everything is OK, and that we lose it after
>> that. I was wondering if the problem is when building that document.
>> Did that changed? or do you have any other ideas of where the problem
>> could be?
> 
> Nope.  Nothing on that code path seems to have changed in the http
> binding.  
> Possibly something in the super classes someplace or the model setup or 
> similar.   Don't really know.   Any chance you can take your interface (at 
> least the affected methods) and setup a small test project that shows the 
> issue and attach to a JIRA?
> 
> Dan
> 
> 
> 
>> Thank you,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
>> > Gabriel,
>> >
>> > Just did a diff of the http binding between 2.1.x branch and the 2.0.7
>> > tag and didn't see anything obvious.   There really were not many
>> changes
>> > to the http binding.
>> >
>> > HOWEVER, I did see one suspect change.   Are you in a position to be
>> able
>> > to patch and test?   Basically, in IriDecoderHelper.java, around line
>> > 334, you should see something that looks like:
>> >
>> >                Node node = ec.getFirstChild();
>> >                while (node != null) {
>> >                    ec.removeChild(node);
>> >                    node = node.getNextSibling();
>> >                }
>> >
>> > I THINK that may be the cause of the problem.   Once the node is
>> removed,
>> > I'm willing to bet the node.getNextSibling() call returns null.   Can
>> you
>> > try changing the code to:
>> >
>> >                Node node = ec.getFirstChild();
>> >                while (node != null) {
>> >                    Node next = node.getNextSibling();
>> >                    ec.removeChild(node);
>> >                    node = next;
>> >                }
>> >
>> > and seeing if that fixes it?
>> >
>> > Dan
>> >
>> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
>> >> Gabriel,
>> >>
>> >> Is it just the createUserWithUser message (and the PUT version) that
>> is
>> >> having the problem or are all the "Gets" also problematic?
>> >>
>> >> That incoming message really looks suspect.   The createUserWithUser
>> >> message isn't namespace qualified at all which would be invalid per
>> any
>> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.     Is
>> >> there any way you could try a POST (with wget or something) of the
>> >> message, but namespace qualify it?    I'm curious if that would work.  
>> >>  Most likely, if you are going to want the message accepted, you'll
>> need
>> >> to write an interceptor that would "fake" a namespace on that element.  
>> >> Basically, wrapper the XMLStreamReader with a new one that would map
>> >> that element name into a qualified version of it.
>> >>
>> >> Dan
>> >>
>> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> >> > Hi Dan and Sergey,
>> >> >
>> >> > >> The main change between them that MAY affect the XML binding is
>> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code from
>> xjc
>> >> > >> can be quite different and could potentially change things.
>> >> >
>> >> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> >> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS
>> for
>> >> > some new web services that we need to build. But we need to keep
>> >> > backward compatibility with the old web services that we have. So
>> the
>> >> > best, meaning less effort, option is to have a fix for HTTP-binding
>> in
>> >> > version 2.2.2. We are planning to migrate this old services, but not
>> >> > now.
>> >> >
>> >> > The problem is only with URL params. All our GET and DELETE services
>> >> > that use some URL param don't work, they always get null values.
>> >> >
>> >> > For example
>> >> >
>> >> > For this service
>> >> >
>> >> > @WebMethod
>> >> > @Get
>> >> > @HttpResource(location = "/users/{username}")
>> >> > WSUser getUserByUsername(@WebParam(name = "username")String
>> username)
>> >> > throws UserNotFoundException;
>> >> >
>> >> > Using this request
>> >> >
>> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
>> >> >
>> >> > It doesn't work. The username param has a null value. Is there a way
>> >> > to get a patch for that?
>> >> >
>> >> > > It is interesting. It would be helpful if Gabriel could post two
>> >> > > sample XML instances, one showing what the clients are currently
>> >> > > getting and what they would get if CXF 2.2.2 were used, we can
>> >> > > proceed from there...
>> >> >
>> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> >> > same XML, the problem is what I mention above, that some methods
>> don't
>> >> > get params. So we were thinking on migrating them to JAX-RS to make
>> it
>> >> > work, but we need to configure it to use the same XML messages
>> format
>> >> > that we  have for HTTP-binding. I'm attaching some xml samples
>> >> > request/response and the interface with the annotations. Sorry that
>> my
>> >> > first post wasn't a clear.
>> >> >
>> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it
>> work,
>> >> > instead of migrating our old stuff. We are planning to migrate them
>> >> > since it was deprecated, but if possible not for our next version,
>> we
>> >> > are short of time for this release and this problem was unexpected.
>> >> >
>> >> > Thanks in advance,
>> >> >
>> >> > Gabriel
>> >> >
>> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
>> >> > Beryozkin<sb...@progress.com>
>> >>
>> >> wrote:
>> >> > > Hi Dan,
>> >> > >
>> >> > >> Sergey,
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards
>> to
>> >> > >> the root element things.   I'm wondering if that may have
>> affected
>> >> > >> this or not.
>> >> > >
>> >> > > possibly...
>> >> > >
>> >> > > thanks, Sergey
>> >> > >
>> >> > >> Dan
>> >> > >>
>> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >> > >>> Hi,
>> >> > >>>
>> >> > >>> As far as I'm aware no significant changes have been made to the
>> >> > >>> HTTP binding recently, I haven't done any work with it for sure.
>> >> > >>> Perhaps there've been some cosmetic changes but I'm not aware of
>> >> > >>> them.
>> >> > >>>
>> >> > >>> We've agreed to deprecate the HTTP binding as all the focus now
>> is
>> >> > >>> on enhancing the JAX-RS runtime.
>> >> > >>>
>> >> > >>> > The problem is that we need to keep the same XML messages
>> format
>> >> > >>> > for
>> >> > >>>
>> >> > >>> backward compatibility.
>> >> > >>>
>> >> > >>> Can you please post a sample class annotated with HTTPBinding
>> >> > >>> annotations and XML message which is expected by current clients
>> ?
>> >> > >>>
>> >> > >>> Thanks, Sergey
>> >> > >>>
>> >> > >>>
>> >> > >>> -----Original Message-----
>> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >> > >>> Sent: 12 June 2009 20:08
>> >> > >>> To: users@cxf.apache.org
>> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the
>> >> > >>> xml messages format?
>> >> > >>>
>> >> > >>>
>> >> > >>> Hi,
>> >> > >>>
>> >> > >>> We have a lot of WS that were implemented using HTTP-binding of
>> >> > >>> CXF 2.0.11,
>> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >> > >>> HTTP-binding do
>> >> > >>> not pass params correctly. So we were trying to migrate those
>> >> > >>> services to
>> >> > >>> JAX-RS. The problem is that we need to keep the same XML
>> messages
>> >> > >>> format for
>> >> > >>> backward compatibility. We tried with the three data binding
>> >> > >>> providers that
>> >> > >>> are in the jaxrs package XMLBeansElementProvider,
>> >> > >>> JAXBElementProvider and
>> >> > >>> AegisElementProvider, but none of them have the same XML format
>> >> > >>> for messages
>> >> > >>> that HTTP-binding has.
>> >> > >>>
>> >> > >>> Is there a way to do so? I mean, to implement services with
>> JAX-RS
>> >> > >>> and use
>> >> > >>> the same XML data binding that has HTTP-binding? Or a way to
>> build
>> >> > >>> the same
>> >> > >>> XML messages?
>> >> > >>>
>> >> > >>> Of course, if there is a way to make HTTP-binding work in
>> version
>> >> > >>> 2.2.2 or
>> >> > >>> 2.1.5, it will be the best solution.
>> >> > >>>
>> >> > >>> Thanks,
>> >> > >>>
>> >> > >>> Gabriel
>> >> > >>
>> >> > >> --
>> >> > >> Daniel Kulp
>> >> > >> dkulp@apache.org
>> >> > >> http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format--tp24004576p24075836.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
On Tue June 16 2009 1:35:43 pm Gabriel Guardincerri wrote:
> Hi Daniel,
>
> I tried that patch, but I'm still getting the same error. I also
> debugged it a little bit and notice that that method is invoked only
> for PUT or POST request. But those type of requests are actually
> working for us with the new version of CXF, we don't have problems
> there. Our problem is with GET or DELETE services that have some
> parameter in the URL, like the "getUserByUsername(String username)"
> example in the files that I sent you.
>
> While debugging I also found that the method
> "IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
> Collection<SchemaInfo> schemas, List<Param> params)" is the one that
> is called for a GET request. And the good news is that when it is
> called it has the parameters that were in the URL and its value. I
> mean, the list "params" has for example one "Param" that is the
> username and its value when I call getUserByUsername service. So it
> seems that at that point everything is OK, and that we lose it after
> that. I was wondering if the problem is when building that document.
> Did that changed? or do you have any other ideas of where the problem
> could be?

Nope.  Nothing on that code path seems to have changed in the http binding.  
Possibly something in the super classes someplace or the model setup or 
similar.   Don't really know.   Any chance you can take your interface (at 
least the affected methods) and setup a small test project that shows the 
issue and attach to a JIRA?

Dan



> Thank you,
>
> Gabriel
>
> On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
> > Gabriel,
> >
> > Just did a diff of the http binding between 2.1.x branch and the 2.0.7
> > tag and didn't see anything obvious.   There really were not many changes
> > to the http binding.
> >
> > HOWEVER, I did see one suspect change.   Are you in a position to be able
> > to patch and test?   Basically, in IriDecoderHelper.java, around line
> > 334, you should see something that looks like:
> >
> >                Node node = ec.getFirstChild();
> >                while (node != null) {
> >                    ec.removeChild(node);
> >                    node = node.getNextSibling();
> >                }
> >
> > I THINK that may be the cause of the problem.   Once the node is removed,
> > I'm willing to bet the node.getNextSibling() call returns null.   Can you
> > try changing the code to:
> >
> >                Node node = ec.getFirstChild();
> >                while (node != null) {
> >                    Node next = node.getNextSibling();
> >                    ec.removeChild(node);
> >                    node = next;
> >                }
> >
> > and seeing if that fixes it?
> >
> > Dan
> >
> > On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
> >> Gabriel,
> >>
> >> Is it just the createUserWithUser message (and the PUT version) that is
> >> having the problem or are all the "Gets" also problematic?
> >>
> >> That incoming message really looks suspect.   The createUserWithUser
> >> message isn't namespace qualified at all which would be invalid per any
> >> of the schema. Thus, I'm surprised that even worked with 2.0.x.     Is
> >> there any way you could try a POST (with wget or something) of the
> >> message, but namespace qualify it?    I'm curious if that would work.  
> >>  Most likely, if you are going to want the message accepted, you'll need
> >> to write an interceptor that would "fake" a namespace on that element.  
> >> Basically, wrapper the XMLStreamReader with a new one that would map
> >> that element name into a qualified version of it.
> >>
> >> Dan
> >>
> >> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> >> > Hi Dan and Sergey,
> >> >
> >> > >> The main change between them that MAY affect the XML binding is
> >> > >> going from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc
> >> > >> can be quite different and could potentially change things.
> >> >
> >> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> >> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> >> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> >> > some new web services that we need to build. But we need to keep
> >> > backward compatibility with the old web services that we have. So the
> >> > best, meaning less effort, option is to have a fix for HTTP-binding in
> >> > version 2.2.2. We are planning to migrate this old services, but not
> >> > now.
> >> >
> >> > The problem is only with URL params. All our GET and DELETE services
> >> > that use some URL param don't work, they always get null values.
> >> >
> >> > For example
> >> >
> >> > For this service
> >> >
> >> > @WebMethod
> >> > @Get
> >> > @HttpResource(location = "/users/{username}")
> >> > WSUser getUserByUsername(@WebParam(name = "username")String username)
> >> > throws UserNotFoundException;
> >> >
> >> > Using this request
> >> >
> >> > GET http://localhost:8080/rpc/rest/userService/users/user1
> >> >
> >> > It doesn't work. The username param has a null value. Is there a way
> >> > to get a patch for that?
> >> >
> >> > > It is interesting. It would be helpful if Gabriel could post two
> >> > > sample XML instances, one showing what the clients are currently
> >> > > getting and what they would get if CXF 2.2.2 were used, we can
> >> > > proceed from there...
> >> >
> >> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> >> > same XML, the problem is what I mention above, that some methods don't
> >> > get params. So we were thinking on migrating them to JAX-RS to make it
> >> > work, but we need to configure it to use the same XML messages format
> >> > that we  have for HTTP-binding. I'm attaching some xml samples
> >> > request/response and the interface with the annotations. Sorry that my
> >> > first post wasn't a clear.
> >> >
> >> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> >> > instead of migrating our old stuff. We are planning to migrate them
> >> > since it was deprecated, but if possible not for our next version, we
> >> > are short of time for this release and this problem was unexpected.
> >> >
> >> > Thanks in advance,
> >> >
> >> > Gabriel
> >> >
> >> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey
> >> > Beryozkin<sb...@progress.com>
> >>
> >> wrote:
> >> > > Hi Dan,
> >> > >
> >> > >> Sergey,
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to
> >> > >> the root element things.   I'm wondering if that may have affected
> >> > >> this or not.
> >> > >
> >> > > possibly...
> >> > >
> >> > > thanks, Sergey
> >> > >
> >> > >> Dan
> >> > >>
> >> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >> > >>> Hi,
> >> > >>>
> >> > >>> As far as I'm aware no significant changes have been made to the
> >> > >>> HTTP binding recently, I haven't done any work with it for sure.
> >> > >>> Perhaps there've been some cosmetic changes but I'm not aware of
> >> > >>> them.
> >> > >>>
> >> > >>> We've agreed to deprecate the HTTP binding as all the focus now is
> >> > >>> on enhancing the JAX-RS runtime.
> >> > >>>
> >> > >>> > The problem is that we need to keep the same XML messages format
> >> > >>> > for
> >> > >>>
> >> > >>> backward compatibility.
> >> > >>>
> >> > >>> Can you please post a sample class annotated with HTTPBinding
> >> > >>> annotations and XML message which is expected by current clients ?
> >> > >>>
> >> > >>> Thanks, Sergey
> >> > >>>
> >> > >>>
> >> > >>> -----Original Message-----
> >> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >> > >>> Sent: 12 June 2009 20:08
> >> > >>> To: users@cxf.apache.org
> >> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the
> >> > >>> xml messages format?
> >> > >>>
> >> > >>>
> >> > >>> Hi,
> >> > >>>
> >> > >>> We have a lot of WS that were implemented using HTTP-binding of
> >> > >>> CXF 2.0.11,
> >> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
> >> > >>> HTTP-binding do
> >> > >>> not pass params correctly. So we were trying to migrate those
> >> > >>> services to
> >> > >>> JAX-RS. The problem is that we need to keep the same XML messages
> >> > >>> format for
> >> > >>> backward compatibility. We tried with the three data binding
> >> > >>> providers that
> >> > >>> are in the jaxrs package XMLBeansElementProvider,
> >> > >>> JAXBElementProvider and
> >> > >>> AegisElementProvider, but none of them have the same XML format
> >> > >>> for messages
> >> > >>> that HTTP-binding has.
> >> > >>>
> >> > >>> Is there a way to do so? I mean, to implement services with JAX-RS
> >> > >>> and use
> >> > >>> the same XML data binding that has HTTP-binding? Or a way to build
> >> > >>> the same
> >> > >>> XML messages?
> >> > >>>
> >> > >>> Of course, if there is a way to make HTTP-binding work in version
> >> > >>> 2.2.2 or
> >> > >>> 2.1.5, it will be the best solution.
> >> > >>>
> >> > >>> Thanks,
> >> > >>>
> >> > >>> Gabriel
> >> > >>
> >> > >> --
> >> > >> Daniel Kulp
> >> > >> dkulp@apache.org
> >> > >> http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Hi Daniel,

I tried that patch, but I'm still getting the same error. I also
debugged it a little bit and notice that that method is invoked only
for PUT or POST request. But those type of requests are actually
working for us with the new version of CXF, we don't have problems
there. Our problem is with GET or DELETE services that have some
parameter in the URL, like the "getUserByUsername(String username)"
example in the files that I sent you.

While debugging I also found that the method
"IriDecoderHelper.buildDocument((XmlSchemaAnnotated schemaAnnotation,
Collection<SchemaInfo> schemas, List<Param> params)" is the one that
is called for a GET request. And the good news is that when it is
called it has the parameters that were in the URL and its value. I
mean, the list "params" has for example one "Param" that is the
username and its value when I call getUserByUsername service. So it
seems that at that point everything is OK, and that we lose it after
that. I was wondering if the problem is when building that document.
Did that changed? or do you have any other ideas of where the problem
could be?

Thank you,

Gabriel


On Mon, Jun 15, 2009 at 5:00 PM, Daniel Kulp<dk...@apache.org> wrote:
>
> Gabriel,
>
> Just did a diff of the http binding between 2.1.x branch and the 2.0.7 tag and
> didn't see anything obvious.   There really were not many changes to the http
> binding.
>
> HOWEVER, I did see one suspect change.   Are you in a position to be able to
> patch and test?   Basically, in IriDecoderHelper.java, around line 334, you
> should see something that looks like:
>
>                Node node = ec.getFirstChild();
>                while (node != null) {
>                    ec.removeChild(node);
>                    node = node.getNextSibling();
>                }
>
> I THINK that may be the cause of the problem.   Once the node is removed, I'm
> willing to bet the node.getNextSibling() call returns null.   Can you try
> changing the code to:
>
>                Node node = ec.getFirstChild();
>                while (node != null) {
>                    Node next = node.getNextSibling();
>                    ec.removeChild(node);
>                    node = next;
>                }
>
> and seeing if that fixes it?
>
> Dan
>
>
>
> On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
>> Gabriel,
>>
>> Is it just the createUserWithUser message (and the PUT version) that is
>> having the problem or are all the "Gets" also problematic?
>>
>> That incoming message really looks suspect.   The createUserWithUser
>> message isn't namespace qualified at all which would be invalid per any of
>> the schema. Thus, I'm surprised that even worked with 2.0.x.     Is there
>> any way you could try a POST (with wget or something) of the message, but
>> namespace qualify it?    I'm curious if that would work.    Most likely, if
>> you are going to want the message accepted, you'll need to write an
>> interceptor that would "fake" a namespace on that element.   Basically,
>> wrapper the XMLStreamReader with a new one that would map that element name
>> into a qualified version of it.
>>
>> Dan
>>
>> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> > Hi Dan and Sergey,
>> >
>> > >> The main change between them that MAY affect the XML binding is going
>> > >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
>> > >> quite different and could potentially change things.
>> >
>> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> > some new web services that we need to build. But we need to keep
>> > backward compatibility with the old web services that we have. So the
>> > best, meaning less effort, option is to have a fix for HTTP-binding in
>> > version 2.2.2. We are planning to migrate this old services, but not
>> > now.
>> >
>> > The problem is only with URL params. All our GET and DELETE services
>> > that use some URL param don't work, they always get null values.
>> >
>> > For example
>> >
>> > For this service
>> >
>> > @WebMethod
>> > @Get
>> > @HttpResource(location = "/users/{username}")
>> > WSUser getUserByUsername(@WebParam(name = "username")String username)
>> > throws UserNotFoundException;
>> >
>> > Using this request
>> >
>> > GET http://localhost:8080/rpc/rest/userService/users/user1
>> >
>> > It doesn't work. The username param has a null value. Is there a way
>> > to get a patch for that?
>> >
>> > > It is interesting. It would be helpful if Gabriel could post two sample
>> > > XML instances, one showing what the clients are currently getting and
>> > > what they would get if CXF 2.2.2 were used, we can proceed from
>> > > there...
>> >
>> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> > same XML, the problem is what I mention above, that some methods don't
>> > get params. So we were thinking on migrating them to JAX-RS to make it
>> > work, but we need to configure it to use the same XML messages format
>> > that we  have for HTTP-binding. I'm attaching some xml samples
>> > request/response and the interface with the annotations. Sorry that my
>> > first post wasn't a clear.
>> >
>> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> > instead of migrating our old stuff. We are planning to migrate them
>> > since it was deprecated, but if possible not for our next version, we
>> > are short of time for this release and this problem was unexpected.
>> >
>> > Thanks in advance,
>> >
>> > Gabriel
>> >
>> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
>>
>> wrote:
>> > > Hi Dan,
>> > >
>> > >> Sergey,
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> > >> root element things.   I'm wondering if that may have affected this or
>> > >> not.
>> > >
>> > > possibly...
>> > >
>> > > thanks, Sergey
>> > >
>> > >> Dan
>> > >>
>> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> > >>> Hi,
>> > >>>
>> > >>> As far as I'm aware no significant changes have been made to the HTTP
>> > >>> binding recently, I haven't done any work with it for sure. Perhaps
>> > >>> there've been some cosmetic changes but I'm not aware of them.
>> > >>>
>> > >>> We've agreed to deprecate the HTTP binding as all the focus now is on
>> > >>> enhancing the JAX-RS runtime.
>> > >>>
>> > >>> > The problem is that we need to keep the same XML messages format
>> > >>> > for
>> > >>>
>> > >>> backward compatibility.
>> > >>>
>> > >>> Can you please post a sample class annotated with HTTPBinding
>> > >>> annotations and XML message which is expected by current clients ?
>> > >>>
>> > >>> Thanks, Sergey
>> > >>>
>> > >>>
>> > >>> -----Original Message-----
>> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> > >>> Sent: 12 June 2009 20:08
>> > >>> To: users@cxf.apache.org
>> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> > >>> messages format?
>> > >>>
>> > >>>
>> > >>> Hi,
>> > >>>
>> > >>> We have a lot of WS that were implemented using HTTP-binding of CXF
>> > >>> 2.0.11,
>> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> > >>> HTTP-binding do
>> > >>> not pass params correctly. So we were trying to migrate those
>> > >>> services to
>> > >>> JAX-RS. The problem is that we need to keep the same XML messages
>> > >>> format for
>> > >>> backward compatibility. We tried with the three data binding
>> > >>> providers that
>> > >>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>> > >>> and
>> > >>> AegisElementProvider, but none of them have the same XML format for
>> > >>> messages
>> > >>> that HTTP-binding has.
>> > >>>
>> > >>> Is there a way to do so? I mean, to implement services with JAX-RS
>> > >>> and use
>> > >>> the same XML data binding that has HTTP-binding? Or a way to build
>> > >>> the same
>> > >>> XML messages?
>> > >>>
>> > >>> Of course, if there is a way to make HTTP-binding work in version
>> > >>> 2.2.2 or
>> > >>> 2.1.5, it will be the best solution.
>> > >>>
>> > >>> Thanks,
>> > >>>
>> > >>> Gabriel
>> > >>
>> > >> --
>> > >> Daniel Kulp
>> > >> dkulp@apache.org
>> > >> http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
Gabriel,

Just did a diff of the http binding between 2.1.x branch and the 2.0.7 tag and 
didn't see anything obvious.   There really were not many changes to the http 
binding.  

HOWEVER, I did see one suspect change.   Are you in a position to be able to 
patch and test?   Basically, in IriDecoderHelper.java, around line 334, you 
should see something that looks like:

                Node node = ec.getFirstChild();
                while (node != null) {
                    ec.removeChild(node);
                    node = node.getNextSibling();
                }

I THINK that may be the cause of the problem.   Once the node is removed, I'm 
willing to bet the node.getNextSibling() call returns null.   Can you try 
changing the code to:

                Node node = ec.getFirstChild();
                while (node != null) {
                    Node next = node.getNextSibling();
                    ec.removeChild(node);
                    node = next;
                }

and seeing if that fixes it?

Dan



On Mon June 15 2009 3:45:50 pm Daniel Kulp wrote:
> Gabriel,
>
> Is it just the createUserWithUser message (and the PUT version) that is
> having the problem or are all the "Gets" also problematic?
>
> That incoming message really looks suspect.   The createUserWithUser
> message isn't namespace qualified at all which would be invalid per any of
> the schema. Thus, I'm surprised that even worked with 2.0.x.     Is there
> any way you could try a POST (with wget or something) of the message, but
> namespace qualify it?    I'm curious if that would work.    Most likely, if
> you are going to want the message accepted, you'll need to write an
> interceptor that would "fake" a namespace on that element.   Basically,
> wrapper the XMLStreamReader with a new one that would map that element name
> into a qualified version of it.
>
> Dan
>
> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> > Hi Dan and Sergey,
> >
> > >> The main change between them that MAY affect the XML binding is going
> > >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
> > >> quite different and could potentially change things.
> >
> > Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> > work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> > appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> > some new web services that we need to build. But we need to keep
> > backward compatibility with the old web services that we have. So the
> > best, meaning less effort, option is to have a fix for HTTP-binding in
> > version 2.2.2. We are planning to migrate this old services, but not
> > now.
> >
> > The problem is only with URL params. All our GET and DELETE services
> > that use some URL param don't work, they always get null values.
> >
> > For example
> >
> > For this service
> >
> > @WebMethod
> > @Get
> > @HttpResource(location = "/users/{username}")
> > WSUser getUserByUsername(@WebParam(name = "username")String username)
> > throws UserNotFoundException;
> >
> > Using this request
> >
> > GET http://localhost:8080/rpc/rest/userService/users/user1
> >
> > It doesn't work. The username param has a null value. Is there a way
> > to get a patch for that?
> >
> > > It is interesting. It would be helpful if Gabriel could post two sample
> > > XML instances, one showing what the clients are currently getting and
> > > what they would get if CXF 2.2.2 were used, we can proceed from
> > > there...
> >
> > Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> > same XML, the problem is what I mention above, that some methods don't
> > get params. So we were thinking on migrating them to JAX-RS to make it
> > work, but we need to configure it to use the same XML messages format
> > that we  have for HTTP-binding. I'm attaching some xml samples
> > request/response and the interface with the annotations. Sorry that my
> > first post wasn't a clear.
> >
> > Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> > instead of migrating our old stuff. We are planning to migrate them
> > since it was deprecated, but if possible not for our next version, we
> > are short of time for this release and this problem was unexpected.
> >
> > Thanks in advance,
> >
> > Gabriel
> >
> > On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
>
> wrote:
> > > Hi Dan,
> > >
> > >> Sergey,
> > >>
> > >>
> > >>
> > >>
> > >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
> > >> root element things.   I'm wondering if that may have affected this or
> > >> not.
> > >
> > > possibly...
> > >
> > > thanks, Sergey
> > >
> > >> Dan
> > >>
> > >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> > >>> Hi,
> > >>>
> > >>> As far as I'm aware no significant changes have been made to the HTTP
> > >>> binding recently, I haven't done any work with it for sure. Perhaps
> > >>> there've been some cosmetic changes but I'm not aware of them.
> > >>>
> > >>> We've agreed to deprecate the HTTP binding as all the focus now is on
> > >>> enhancing the JAX-RS runtime.
> > >>>
> > >>> > The problem is that we need to keep the same XML messages format
> > >>> > for
> > >>>
> > >>> backward compatibility.
> > >>>
> > >>> Can you please post a sample class annotated with HTTPBinding
> > >>> annotations and XML message which is expected by current clients ?
> > >>>
> > >>> Thanks, Sergey
> > >>>
> > >>>
> > >>> -----Original Message-----
> > >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> > >>> Sent: 12 June 2009 20:08
> > >>> To: users@cxf.apache.org
> > >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> > >>> messages format?
> > >>>
> > >>>
> > >>> Hi,
> > >>>
> > >>> We have a lot of WS that were implemented using HTTP-binding of CXF
> > >>> 2.0.11,
> > >>> but when we tried to migrate CXF to 2.2.2 we found out that
> > >>> HTTP-binding do
> > >>> not pass params correctly. So we were trying to migrate those
> > >>> services to
> > >>> JAX-RS. The problem is that we need to keep the same XML messages
> > >>> format for
> > >>> backward compatibility. We tried with the three data binding
> > >>> providers that
> > >>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
> > >>> and
> > >>> AegisElementProvider, but none of them have the same XML format for
> > >>> messages
> > >>> that HTTP-binding has.
> > >>>
> > >>> Is there a way to do so? I mean, to implement services with JAX-RS
> > >>> and use
> > >>> the same XML data binding that has HTTP-binding? Or a way to build
> > >>> the same
> > >>> XML messages?
> > >>>
> > >>> Of course, if there is a way to make HTTP-binding work in version
> > >>> 2.2.2 or
> > >>> 2.1.5, it will be the best solution.
> > >>>
> > >>> Thanks,
> > >>>
> > >>> Gabriel
> > >>
> > >> --
> > >> Daniel Kulp
> > >> dkulp@apache.org
> > >> http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Daniel,

Oh intresting, actually only "GET" and "DELETE" that have params in
the URL have problems. All PUTs and POSTs (or GET/DELETE without
params) work. Anyway those incoming messages are just for testing
proposes, so we can changed them to be namespace qualified. Thanks for
the finding.

Gabriel

On Mon, Jun 15, 2009 at 4:45 PM, Daniel Kulp<dk...@apache.org> wrote:
>
> Gabriel,
>
> Is it just the createUserWithUser message (and the PUT version) that is having
> the problem or are all the "Gets" also problematic?
>
> That incoming message really looks suspect.   The createUserWithUser message
> isn't namespace qualified at all which would be invalid per any of the schema.
> Thus, I'm surprised that even worked with 2.0.x.     Is there any way you
> could try a POST (with wget or something) of the message, but namespace
> qualify it?    I'm curious if that would work.    Most likely, if you are
> going to want the message accepted, you'll need to write an interceptor that
> would "fake" a namespace on that element.   Basically, wrapper the
> XMLStreamReader with a new one that would map that element name into a
> qualified version of it.
>
> Dan
>
>
>
> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> Hi Dan and Sergey,
>>
>> >> The main change between them that MAY affect the XML binding is going
>> >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
>> >> quite different and could potentially change things.
>>
>> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> some new web services that we need to build. But we need to keep
>> backward compatibility with the old web services that we have. So the
>> best, meaning less effort, option is to have a fix for HTTP-binding in
>> version 2.2.2. We are planning to migrate this old services, but not
>> now.
>>
>> The problem is only with URL params. All our GET and DELETE services
>> that use some URL param don't work, they always get null values.
>>
>> For example
>>
>> For this service
>>
>> @WebMethod
>> @Get
>> @HttpResource(location = "/users/{username}")
>> WSUser getUserByUsername(@WebParam(name = "username")String username)
>> throws UserNotFoundException;
>>
>> Using this request
>>
>> GET http://localhost:8080/rpc/rest/userService/users/user1
>>
>> It doesn't work. The username param has a null value. Is there a way
>> to get a patch for that?
>>
>> > It is interesting. It would be helpful if Gabriel could post two sample
>> > XML instances, one showing what the clients are currently getting and
>> > what they would get if CXF 2.2.2 were used, we can proceed from there...
>>
>> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> same XML, the problem is what I mention above, that some methods don't
>> get params. So we were thinking on migrating them to JAX-RS to make it
>> work, but we need to configure it to use the same XML messages format
>> that we  have for HTTP-binding. I'm attaching some xml samples
>> request/response and the interface with the annotations. Sorry that my
>> first post wasn't a clear.
>>
>> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> instead of migrating our old stuff. We are planning to migrate them
>> since it was deprecated, but if possible not for our next version, we
>> are short of time for this release and this problem was unexpected.
>>
>> Thanks in advance,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
> wrote:
>> > Hi Dan,
>> >
>> >> Sergey,
>> >>
>> >>
>> >>
>> >>
>> >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> >> root element things.   I'm wondering if that may have affected this or
>> >> not.
>> >
>> > possibly...
>> >
>> > thanks, Sergey
>> >
>> >> Dan
>> >>
>> >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >>> Hi,
>> >>>
>> >>> As far as I'm aware no significant changes have been made to the HTTP
>> >>> binding recently, I haven't done any work with it for sure. Perhaps
>> >>> there've been some cosmetic changes but I'm not aware of them.
>> >>>
>> >>> We've agreed to deprecate the HTTP binding as all the focus now is on
>> >>> enhancing the JAX-RS runtime.
>> >>>
>> >>> > The problem is that we need to keep the same XML messages format for
>> >>>
>> >>> backward compatibility.
>> >>>
>> >>> Can you please post a sample class annotated with HTTPBinding
>> >>> annotations and XML message which is expected by current clients ?
>> >>>
>> >>> Thanks, Sergey
>> >>>
>> >>>
>> >>> -----Original Message-----
>> >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >>> Sent: 12 June 2009 20:08
>> >>> To: users@cxf.apache.org
>> >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> >>> messages format?
>> >>>
>> >>>
>> >>> Hi,
>> >>>
>> >>> We have a lot of WS that were implemented using HTTP-binding of CXF
>> >>> 2.0.11,
>> >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >>> HTTP-binding do
>> >>> not pass params correctly. So we were trying to migrate those services
>> >>> to
>> >>> JAX-RS. The problem is that we need to keep the same XML messages
>> >>> format for
>> >>> backward compatibility. We tried with the three data binding providers
>> >>> that
>> >>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>> >>> and
>> >>> AegisElementProvider, but none of them have the same XML format for
>> >>> messages
>> >>> that HTTP-binding has.
>> >>>
>> >>> Is there a way to do so? I mean, to implement services with JAX-RS and
>> >>> use
>> >>> the same XML data binding that has HTTP-binding? Or a way to build the
>> >>> same
>> >>> XML messages?
>> >>>
>> >>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>> >>> or
>> >>> 2.1.5, it will be the best solution.
>> >>>
>> >>> Thanks,
>> >>>
>> >>> Gabriel
>> >>
>> >> --
>> >> Daniel Kulp
>> >> dkulp@apache.org
>> >> http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Hi Daniel,

Could you give an example of a qualified namespace for this?

Thanks,

Gabriel


dkulp wrote:
> 
> 
> Gabriel,
> 
> Is it just the createUserWithUser message (and the PUT version) that is
> having 
> the problem or are all the "Gets" also problematic?  
> 
> That incoming message really looks suspect.   The createUserWithUser
> message 
> isn't namespace qualified at all which would be invalid per any of the
> schema.   
> Thus, I'm surprised that even worked with 2.0.x.     Is there any way you 
> could try a POST (with wget or something) of the message, but namespace 
> qualify it?    I'm curious if that would work.    Most likely, if you are 
> going to want the message accepted, you'll need to write an interceptor
> that 
> would "fake" a namespace on that element.   Basically, wrapper the 
> XMLStreamReader with a new one that would map that element name into a 
> qualified version of it.
> 
> Dan
> 
> 
> 
> On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
>> Hi Dan and Sergey,
>>
>> >> The main change between them that MAY affect the XML binding is going
>> >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
>> >> quite different and could potentially change things.
>>
>> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> some new web services that we need to build. But we need to keep
>> backward compatibility with the old web services that we have. So the
>> best, meaning less effort, option is to have a fix for HTTP-binding in
>> version 2.2.2. We are planning to migrate this old services, but not
>> now.
>>
>> The problem is only with URL params. All our GET and DELETE services
>> that use some URL param don't work, they always get null values.
>>
>> For example
>>
>> For this service
>>
>> @WebMethod
>> @Get
>> @HttpResource(location = "/users/{username}")
>> WSUser getUserByUsername(@WebParam(name = "username")String username)
>> throws UserNotFoundException;
>>
>> Using this request
>>
>> GET http://localhost:8080/rpc/rest/userService/users/user1
>>
>> It doesn't work. The username param has a null value. Is there a way
>> to get a patch for that?
>>
>> > It is interesting. It would be helpful if Gabriel could post two sample
>> > XML instances, one showing what the clients are currently getting and
>> > what they would get if CXF 2.2.2 were used, we can proceed from
>> there...
>>
>> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> same XML, the problem is what I mention above, that some methods don't
>> get params. So we were thinking on migrating them to JAX-RS to make it
>> work, but we need to configure it to use the same XML messages format
>> that we  have for HTTP-binding. I'm attaching some xml samples
>> request/response and the interface with the annotations. Sorry that my
>> first post wasn't a clear.
>>
>> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> instead of migrating our old stuff. We are planning to migrate them
>> since it was deprecated, but if possible not for our next version, we
>> are short of time for this release and this problem was unexpected.
>>
>> Thanks in advance,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> 
> wrote:
>> > Hi Dan,
>> >
>> >> Sergey,
>> >>
>> >>
>> >>
>> >>
>> >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> >> root element things.   I'm wondering if that may have affected this or
>> >> not.
>> >
>> > possibly...
>> >
>> > thanks, Sergey
>> >
>> >> Dan
>> >>
>> >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> >>> Hi,
>> >>>
>> >>> As far as I'm aware no significant changes have been made to the HTTP
>> >>> binding recently, I haven't done any work with it for sure. Perhaps
>> >>> there've been some cosmetic changes but I'm not aware of them.
>> >>>
>> >>> We've agreed to deprecate the HTTP binding as all the focus now is on
>> >>> enhancing the JAX-RS runtime.
>> >>>
>> >>> > The problem is that we need to keep the same XML messages format
>> for
>> >>>
>> >>> backward compatibility.
>> >>>
>> >>> Can you please post a sample class annotated with HTTPBinding
>> >>> annotations and XML message which is expected by current clients ?
>> >>>
>> >>> Thanks, Sergey
>> >>>
>> >>>
>> >>> -----Original Message-----
>> >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> >>> Sent: 12 June 2009 20:08
>> >>> To: users@cxf.apache.org
>> >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> >>> messages format?
>> >>>
>> >>>
>> >>> Hi,
>> >>>
>> >>> We have a lot of WS that were implemented using HTTP-binding of CXF
>> >>> 2.0.11,
>> >>> but when we tried to migrate CXF to 2.2.2 we found out that
>> >>> HTTP-binding do
>> >>> not pass params correctly. So we were trying to migrate those
>> services
>> >>> to
>> >>> JAX-RS. The problem is that we need to keep the same XML messages
>> >>> format for
>> >>> backward compatibility. We tried with the three data binding
>> providers
>> >>> that
>> >>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>> >>> and
>> >>> AegisElementProvider, but none of them have the same XML format for
>> >>> messages
>> >>> that HTTP-binding has.
>> >>>
>> >>> Is there a way to do so? I mean, to implement services with JAX-RS
>> and
>> >>> use
>> >>> the same XML data binding that has HTTP-binding? Or a way to build
>> the
>> >>> same
>> >>> XML messages?
>> >>>
>> >>> Of course, if there is a way to make HTTP-binding work in version
>> 2.2.2
>> >>> or
>> >>> 2.1.5, it will be the best solution.
>> >>>
>> >>> Thanks,
>> >>>
>> >>> Gabriel
>> >>
>> >> --
>> >> Daniel Kulp
>> >> dkulp@apache.org
>> >> http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format--tp24004576p24059529.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
Gabriel,

Is it just the createUserWithUser message (and the PUT version) that is having 
the problem or are all the "Gets" also problematic?  

That incoming message really looks suspect.   The createUserWithUser message 
isn't namespace qualified at all which would be invalid per any of the schema.   
Thus, I'm surprised that even worked with 2.0.x.     Is there any way you 
could try a POST (with wget or something) of the message, but namespace 
qualify it?    I'm curious if that would work.    Most likely, if you are 
going to want the message accepted, you'll need to write an interceptor that 
would "fake" a namespace on that element.   Basically, wrapper the 
XMLStreamReader with a new one that would map that element name into a 
qualified version of it.

Dan



On Mon June 15 2009 3:16:03 pm Gabriel Guardincerri wrote:
> Hi Dan and Sergey,
>
> >> The main change between them that MAY affect the XML binding is going
> >> from JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be
> >> quite different and could potentially change things.
>
> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> some new web services that we need to build. But we need to keep
> backward compatibility with the old web services that we have. So the
> best, meaning less effort, option is to have a fix for HTTP-binding in
> version 2.2.2. We are planning to migrate this old services, but not
> now.
>
> The problem is only with URL params. All our GET and DELETE services
> that use some URL param don't work, they always get null values.
>
> For example
>
> For this service
>
> @WebMethod
> @Get
> @HttpResource(location = "/users/{username}")
> WSUser getUserByUsername(@WebParam(name = "username")String username)
> throws UserNotFoundException;
>
> Using this request
>
> GET http://localhost:8080/rpc/rest/userService/users/user1
>
> It doesn't work. The username param has a null value. Is there a way
> to get a patch for that?
>
> > It is interesting. It would be helpful if Gabriel could post two sample
> > XML instances, one showing what the clients are currently getting and
> > what they would get if CXF 2.2.2 were used, we can proceed from there...
>
> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> same XML, the problem is what I mention above, that some methods don't
> get params. So we were thinking on migrating them to JAX-RS to make it
> work, but we need to configure it to use the same XML messages format
> that we  have for HTTP-binding. I'm attaching some xml samples
> request/response and the interface with the annotations. Sorry that my
> first post wasn't a clear.
>
> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> instead of migrating our old stuff. We are planning to migrate them
> since it was deprecated, but if possible not for our next version, we
> are short of time for this release and this problem was unexpected.
>
> Thanks in advance,
>
> Gabriel
>
> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> 
wrote:
> > Hi Dan,
> >
> >> Sergey,
> >>
> >>
> >>
> >>
> >> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
> >> root element things.   I'm wondering if that may have affected this or
> >> not.
> >
> > possibly...
> >
> > thanks, Sergey
> >
> >> Dan
> >>
> >> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> >>> Hi,
> >>>
> >>> As far as I'm aware no significant changes have been made to the HTTP
> >>> binding recently, I haven't done any work with it for sure. Perhaps
> >>> there've been some cosmetic changes but I'm not aware of them.
> >>>
> >>> We've agreed to deprecate the HTTP binding as all the focus now is on
> >>> enhancing the JAX-RS runtime.
> >>>
> >>> > The problem is that we need to keep the same XML messages format for
> >>>
> >>> backward compatibility.
> >>>
> >>> Can you please post a sample class annotated with HTTPBinding
> >>> annotations and XML message which is expected by current clients ?
> >>>
> >>> Thanks, Sergey
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> >>> Sent: 12 June 2009 20:08
> >>> To: users@cxf.apache.org
> >>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> >>> messages format?
> >>>
> >>>
> >>> Hi,
> >>>
> >>> We have a lot of WS that were implemented using HTTP-binding of CXF
> >>> 2.0.11,
> >>> but when we tried to migrate CXF to 2.2.2 we found out that
> >>> HTTP-binding do
> >>> not pass params correctly. So we were trying to migrate those services
> >>> to
> >>> JAX-RS. The problem is that we need to keep the same XML messages
> >>> format for
> >>> backward compatibility. We tried with the three data binding providers
> >>> that
> >>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
> >>> and
> >>> AegisElementProvider, but none of them have the same XML format for
> >>> messages
> >>> that HTTP-binding has.
> >>>
> >>> Is there a way to do so? I mean, to implement services with JAX-RS and
> >>> use
> >>> the same XML data binding that has HTTP-binding? Or a way to build the
> >>> same
> >>> XML messages?
> >>>
> >>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
> >>> or
> >>> 2.1.5, it will be the best solution.
> >>>
> >>> Thanks,
> >>>
> >>> Gabriel
> >>
> >> --
> >> Daniel Kulp
> >> dkulp@apache.org
> >> http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabriel

ok. here's what to be done in case you decide to try to it later on :

1. Here's how you can register a stax writer using a jaxrs filter :

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamWriterProvider.java

In your case you would also need to check if it's GET and extract an actual class method name :

ori.getMethodToInvoke().getName() and pass it to a custom writer

2. Here's a custom writer

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomXmlStreamWriter.java

so you only override writeStartElement/endElement, and you write a boilerplate code, using the name of the operation, etc

JAXBProvider will use the custom writer to write to.

I think it is all that needs to be done. Similarly a stax Reader can be created if needed from a RequestHandler filter.
IMHO it's quite straighforward, but I appreciate it may not be that easy to do in the actual production env.
Let me know if you have any questions in case you decide to experiment a bit with this approach.

Cheers, Sergey





----- Original Message ----- 
From: "Gabriel Guardincerri" <gg...@gmail.com>
To: <us...@cxf.apache.org>
Sent: Wednesday, June 17, 2009 3:59 PM
Subject: RE: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?



Hi Sergey,

Thank you for your detailed post. It seems to be really hard to have the
same XML format. For now, I'll wait for a patch to HTTP-binging, I'm also
debuging it myself trying to see if I find the problem. But we will probably
need to think on the alternative of breaking backward compatibility and to
migrate all to standard JAXRS for future releases.

Thank you,

Gabriel


Sergey Beryozkin-2 wrote:
>
> Hi,
>
> I think a response like
>
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
>   </return>
> </ns1:getUserByUsernameResponse>
>
> indicates that a response being formatted/wrapped according to soap rules,
> so it is unlikely the JAXRS runtime will be capable of formatting the same
> way. Now, I'm planning to support CXF Data Bindings wrapped as JAXRS
> message providers but I'm not sure it will help in this case.
>
> So with JAX-RS/JAXB you'll have something like
>
> <user xmlns="somenamespace">
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
> </user>
>
>
> I don't see what can be done at the JAXRS level to ensure that the
> HTTP-Binding like response is returned. You may want just to move to
> JAX-RS right now rather than postponing it and register an XMLStreamWriter
> from a JAXRS ResponseHandler filter which upon encountering a root element
> would replace it with a boilerplate xml like
>
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>
> and then after letting the document out finish it with
> </return>
> </ns1:getUserByUsernameResponse>
>
> I'm presuming the name of the operation is "getUserByUsername", you can
> get it from an input message which you can pass into your custom stax
> writer upon creating it in the filter.
>
> If your legacy clients were distinguishable somehow from the newer ones
> (say they have some unique header, etc) then you can do it for old clients
> only.
>
> It is just difficult for us to continue working with the HTTP Binding
> given that JAX-RS is a much richer spec. I'd vote for dropping it
> completely for 2.3 given that various new contributions are expected
> though still maintaining it in 2.2 fixes.
>
> Now about the list response :
>
> <ns1:getUsersResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </return>
>   <return>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </return>
> </ns1:getUsersResponse>
>
> May be we should do in JAX-RS something like
>
> <users xmlns="namespace used by user or package name derived">
>   <user>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </user>
>   <user>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </user>
> </users>
>
> And also introduce some annotations which will give a hint to the runtime
> on how to customize the wrapping of the list
>
> Cheers, Sergey
>
>
>
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> Sent: 16 June 2009 19:37
> To: users@cxf.apache.org
> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> messages format?
>
> Hi Sergey,
>
>>
>> So what difference in formats is there when you try to switch to JAX-RS
>> (with JAXB 2.1 being the default provider) ? When you switch, do you
>> issues with all the XML samples you posted or is it with PUT only ?
>
> When I switch to JAX-RS with it's default provider I have problems
> with all the methods that are in the XML samples. But for PUT or POST
> I'm getting a java error, so it may be the qualified namespace that
> Daniel mention, I trying to fix and test it again.
>
> On the other side there are differences with GET requests.
>
> For the service "Get User", I get:
>
> Request:
>
> GET http://localhost:8080/rpc/rest/userService/users/user1
>
> Responses:
>
> With HTTP-binding in 2.0.x:
>
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
>   </return>
> </ns1:getUserByUsernameResponse>
>
> With JAX-RS with its default provider in 2.2.2:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <User>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
> </User>
>
> And for service "Get Users"
>
> Request
>
> GET http://localhost:8080/rpc/rest/userService/users
>
> Responses:
>
> With HTTP-binding in 2.0.x:
>
> <ns1:getUsersResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </return>
>   <return>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </return>
> </ns1:getUsersResponse>
>
> With JAX-RS with its default provider in 2.2.2:
>
> ".No message body writer found for response class : ArrayList."
>
>
>> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF
>> interceptors or JAX-RS filters). For ex, you can check if it's PUT and no
>> namespace is there and adapt as needed - let us know please if/when you
>> decide to go this route to make a smoother migration, we can provide some
>> code samples...
>
> Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
> they work with HTTP-binding in that version. If we couldn't find a
> solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
> this route and I'll appreciate code samples :). But for now I just
> prefer to see how HTTP-binding fix goes before going this way that
> will imply code migration and a fix to the xml messages format issue.
>
> Thank you,
>
> Gabriel
>
>>
>>
>>
>>
>> -----Original Message-----
>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> Sent: 15 June 2009 20:16
>> To: users@cxf.apache.org
>> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> messages format?
>>
>> Hi Dan and Sergey,
>>
>>>> The main change between them that MAY affect the XML binding is going
>>>> from
>>>> JAXB 2.0.x to JAXB 2.1.x. The generated code from xjc can be quite
>>>> different and could potentially change things.
>>
>> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> some new web services that we need to build. But we need to keep
>> backward compatibility with the old web services that we have. So the
>> best, meaning less effort, option is to have a fix for HTTP-binding in
>> version 2.2.2. We are planning to migrate this old services, but not
>> now.
>>
>> The problem is only with URL params. All our GET and DELETE services
>> that use some URL param don't work, they always get null values.
>>
>> For example
>>
>> For this service
>>
>> @WebMethod
>> @Get
>> @HttpResource(location = "/users/{username}")
>> WSUser getUserByUsername(@WebParam(name = "username")String username)
>> throws UserNotFoundException;
>>
>> Using this request
>>
>> GET http://localhost:8080/rpc/rest/userService/users/user1
>>
>> It doesn't work. The username param has a null value. Is there a way
>> to get a patch for that?
>>
>>> It is interesting. It would be helpful if Gabriel could post two sample
>>> XML
>>> instances, one showing what the clients are currently getting and what
>>> they
>>> would get if CXF 2.2.2 were used, we can proceed from there...
>>
>> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> same XML, the problem is what I mention above, that some methods don't
>> get params. So we were thinking on migrating them to JAX-RS to make it
>> work, but we need to configure it to use the same XML messages format
>> that we have for HTTP-binding. I'm attaching some xml samples
>> request/response and the interface with the annotations. Sorry that my
>> first post wasn't a clear.
>>
>> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> instead of migrating our old stuff. We are planning to migrate them
>> since it was deprecated, but if possible not for our next version, we
>> are short of time for this release and this problem was unexpected.
>>
>> Thanks in advance,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
>> wrote:
>>> Hi Dan,
>>>
>>>
>>>
>>>>
>>>> Sergey,
>>>>
>>>
>>>
>>>>
>>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>>>> root element things. I'm wondering if that may have affected this or
>>>> not.
>>>>
>>>
>>> possibly...
>>>
>>> thanks, Sergey
>>>
>>>>
>>>> Dan
>>>>
>>>>
>>>>
>>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> As far as I'm aware no significant changes have been made to the HTTP
>>>>> binding recently, I haven't done any work with it for sure. Perhaps
>>>>> there've been some cosmetic changes but I'm not aware of them.
>>>>>
>>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>>>> enhancing the JAX-RS runtime.
>>>>>
>>>>> > The problem is that we need to keep the same XML messages format for
>>>>>
>>>>> backward compatibility.
>>>>>
>>>>> Can you please post a sample class annotated with HTTPBinding
>>>>> annotations and XML message which is expected by current clients ?
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>>>> Sent: 12 June 2009 20:08
>>>>> To: users@cxf.apache.org
>>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>>>> messages format?
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>>>> 2.0.11,
>>>>> but when we tried to migrate CXF to 2.2.2 we found out that
>>>>> HTTP-binding
>>>>> do
>>>>> not pass params correctly. So we were trying to migrate those services
>>>>> to
>>>>> JAX-RS. The problem is that we need to keep the same XML messages
>>>>> format
>>>>> for
>>>>> backward compatibility. We tried with the three data binding providers
>>>>> that
>>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>>>> and
>>>>> AegisElementProvider, but none of them have the same XML format for
>>>>> messages
>>>>> that HTTP-binding has.
>>>>>
>>>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>>>> use
>>>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>>>> same
>>>>> XML messages?
>>>>>
>>>>> Of course, if there is a way to make HTTP-binding work in version
>>>>> 2.2.2
>>>>> or
>>>>> 2.1.5, it will be the best solution.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Gabriel
>>>>
>>>> --
>>>> Daniel Kulp
>>>> dkulp@apache.org
>>>> http://www.dankulp.com/blog
>>>
>>
>
>

-- 
View this message in context: 
http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format--tp24004576p24075533.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Hi Sergey,

Thank you for your detailed post. It seems to be really hard to have the
same XML format. For now, I'll wait for a patch to HTTP-binging, I'm also
debuging it myself trying to see if I find the problem. But we will probably
need to think on the alternative of breaking backward compatibility and to
migrate all to standard JAXRS for future releases.

Thank you,

Gabriel


Sergey Beryozkin-2 wrote:
> 
> Hi,
> 
> I think a response like
> 
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
>   </return>
> </ns1:getUserByUsernameResponse>
> 
> indicates that a response being formatted/wrapped according to soap rules,
> so it is unlikely the JAXRS runtime will be capable of formatting the same
> way. Now, I'm planning to support CXF Data Bindings wrapped as JAXRS
> message providers but I'm not sure it will help in this case.
> 
> So with JAX-RS/JAXB you'll have something like
> 
> <user xmlns="somenamespace">
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
> </user>
> 
> 
> I don't see what can be done at the JAXRS level to ensure that the
> HTTP-Binding like response is returned. You may want just to move to
> JAX-RS right now rather than postponing it and register an XMLStreamWriter
> from a JAXRS ResponseHandler filter which upon encountering a root element
> would replace it with a boilerplate xml like
> 
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     
> and then after letting the document out finish it with  
> </return>
> </ns1:getUserByUsernameResponse>
> 
> I'm presuming the name of the operation is "getUserByUsername", you can
> get it from an input message which you can pass into your custom stax
> writer upon creating it in the filter.
> 
> If your legacy clients were distinguishable somehow from the newer ones
> (say they have some unique header, etc) then you can do it for old clients
> only.
> 
> It is just difficult for us to continue working with the HTTP Binding
> given that JAX-RS is a much richer spec. I'd vote for dropping it
> completely for 2.3 given that various new contributions are expected
> though still maintaining it in 2.2 fixes. 
> 
> Now about the list response :
> 
> <ns1:getUsersResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </return>
>   <return>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </return>
> </ns1:getUsersResponse>
> 
> May be we should do in JAX-RS something like 
> 
> <users xmlns="namespace used by user or package name derived">
>   <user>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </user>
>   <user>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </user>
> </users> 
> 
> And also introduce some annotations which will give a hint to the runtime
> on how to customize the wrapping of the list
> 
> Cheers, Sergey
> 
> 
> 
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com] 
> Sent: 16 June 2009 19:37
> To: users@cxf.apache.org
> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> messages format?
> 
> Hi Sergey,
> 
>>
>> So what difference in formats is there when you try to switch to JAX-RS
>> (with JAXB 2.1 being the default provider) ? When you switch, do you
>> issues with all the XML samples you posted or is it with PUT only ?
> 
> When I switch to JAX-RS with it's default provider I have problems
> with all the methods that are in the XML samples. But for PUT or POST
> I'm getting a java error, so it may be the qualified namespace that
> Daniel mention, I trying to fix and test it again.
> 
> On the other side there are differences with GET requests.
> 
> For the service "Get User", I get:
> 
> Request:
> 
> GET http://localhost:8080/rpc/rest/userService/users/user1
> 
> Responses:
> 
> With HTTP-binding in 2.0.x:
> 
> <ns1:getUserByUsernameResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
>   </return>
> </ns1:getUserByUsernameResponse>
> 
> With JAX-RS with its default provider in 2.2.2:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <User>
>     user1@fsdfsd.com
>     <ID>2001</ID>
>     <name>user1 user1</name>
>     <username>user1</username>
> </User>
> 
> And for service "Get Users"
> 
> Request
> 
> GET http://localhost:8080/rpc/rest/userService/users
> 
> Responses:
> 
> With HTTP-binding in 2.0.x:
> 
> <ns1:getUsersResponse
> xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
>   <return>
>     test@test.com
>     <ID>2003</ID>
>     <name>User Test One</name>
>     <username>userTest1</username>
>   </return>
>   <return>
>     user2@mail.com
>     <ID>2002</ID>
>     <name>user2 user2</name>
>     <username>user2</username>
>   </return>
> </ns1:getUsersResponse>
> 
> With JAX-RS with its default provider in 2.2.2:
> 
> ".No message body writer found for response class : ArrayList."
> 
> 
>> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF
>> interceptors or JAX-RS filters). For ex, you can check if it's PUT and no
>> namespace is there and adapt as needed - let us know please if/when you
>> decide to go this route to make a smoother migration, we can provide some
>> code samples...
> 
> Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
> they work with HTTP-binding in that version. If we couldn't find a
> solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
> this route and I'll appreciate code samples :). But for now I just
> prefer to see how HTTP-binding fix goes before going this way that
> will imply code migration and a fix to the xml messages format issue.
> 
> Thank you,
> 
> Gabriel
> 
>>
>>
>>
>>
>> -----Original Message-----
>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> Sent: 15 June 2009 20:16
>> To: users@cxf.apache.org
>> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> messages format?
>>
>> Hi Dan and Sergey,
>>
>>>> The main change between them that MAY affect the XML binding is going
>>>> from
>>>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>>>> different and could potentially change things.
>>
>> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
>> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
>> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
>> some new web services that we need to build. But we need to keep
>> backward compatibility with the old web services that we have. So the
>> best, meaning less effort, option is to have a fix for HTTP-binding in
>> version 2.2.2. We are planning to migrate this old services, but not
>> now.
>>
>> The problem is only with URL params. All our GET and DELETE services
>> that use some URL param don't work, they always get null values.
>>
>> For example
>>
>> For this service
>>
>> @WebMethod
>> @Get
>> @HttpResource(location = "/users/{username}")
>> WSUser getUserByUsername(@WebParam(name = "username")String username)
>> throws UserNotFoundException;
>>
>> Using this request
>>
>> GET http://localhost:8080/rpc/rest/userService/users/user1
>>
>> It doesn't work. The username param has a null value. Is there a way
>> to get a patch for that?
>>
>>> It is interesting. It would be helpful if Gabriel could post two sample
>>> XML
>>> instances, one showing what the clients are currently getting and what
>>> they
>>> would get if CXF 2.2.2 were used, we can proceed from there...
>>
>> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
>> same XML, the problem is what I mention above, that some methods don't
>> get params. So we were thinking on migrating them to JAX-RS to make it
>> work, but we need to configure it to use the same XML messages format
>> that we  have for HTTP-binding. I'm attaching some xml samples
>> request/response and the interface with the annotations. Sorry that my
>> first post wasn't a clear.
>>
>> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
>> instead of migrating our old stuff. We are planning to migrate them
>> since it was deprecated, but if possible not for our next version, we
>> are short of time for this release and this problem was unexpected.
>>
>> Thanks in advance,
>>
>> Gabriel
>>
>> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com>
>> wrote:
>>> Hi Dan,
>>>
>>>
>>>
>>>>
>>>> Sergey,
>>>>
>>>
>>>
>>>>
>>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>>>> root element things.   I'm wondering if that may have affected this or
>>>> not.
>>>>
>>>
>>> possibly...
>>>
>>> thanks, Sergey
>>>
>>>>
>>>> Dan
>>>>
>>>>
>>>>
>>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> As far as I'm aware no significant changes have been made to the HTTP
>>>>> binding recently, I haven't done any work with it for sure. Perhaps
>>>>> there've been some cosmetic changes but I'm not aware of them.
>>>>>
>>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>>>> enhancing the JAX-RS runtime.
>>>>>
>>>>> > The problem is that we need to keep the same XML messages format for
>>>>>
>>>>> backward compatibility.
>>>>>
>>>>> Can you please post a sample class annotated with HTTPBinding
>>>>> annotations and XML message which is expected by current clients ?
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>>>> Sent: 12 June 2009 20:08
>>>>> To: users@cxf.apache.org
>>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>>>> messages format?
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>>>> 2.0.11,
>>>>> but when we tried to migrate CXF to 2.2.2 we found out that
>>>>> HTTP-binding
>>>>> do
>>>>> not pass params correctly. So we were trying to migrate those services
>>>>> to
>>>>> JAX-RS. The problem is that we need to keep the same XML messages
>>>>> format
>>>>> for
>>>>> backward compatibility. We tried with the three data binding providers
>>>>> that
>>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>>>> and
>>>>> AegisElementProvider, but none of them have the same XML format for
>>>>> messages
>>>>> that HTTP-binding has.
>>>>>
>>>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>>>> use
>>>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>>>> same
>>>>> XML messages?
>>>>>
>>>>> Of course, if there is a way to make HTTP-binding work in version
>>>>> 2.2.2
>>>>> or
>>>>> 2.1.5, it will be the best solution.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Gabriel
>>>>
>>>> --
>>>> Daniel Kulp
>>>> dkulp@apache.org
>>>> http://www.dankulp.com/blog
>>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-keep-the-xml-messages-format--tp24004576p24075533.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

I think a response like

<ns1:getUserByUsernameResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
  </return>
</ns1:getUserByUsernameResponse>

indicates that a response being formatted/wrapped according to soap rules, so it is unlikely the JAXRS runtime will be capable of formatting the same way. Now, I'm planning to support CXF Data Bindings wrapped as JAXRS message providers but I'm not sure it will help in this case.

So with JAX-RS/JAXB you'll have something like

<user xmlns="somenamespace">
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
</user>


I don't see what can be done at the JAXRS level to ensure that the HTTP-Binding like response is returned. You may want just to move to JAX-RS right now rather than postponing it and register an XMLStreamWriter from a JAXRS ResponseHandler filter which upon encountering a root element would replace it with a boilerplate xml like

<ns1:getUserByUsernameResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    
and then after letting the document out finish it with  
</return>
</ns1:getUserByUsernameResponse>

I'm presuming the name of the operation is "getUserByUsername", you can get it from an input message which you can pass into your custom stax writer upon creating it in the filter.

If your legacy clients were distinguishable somehow from the newer ones (say they have some unique header, etc) then you can do it for old clients only.

It is just difficult for us to continue working with the HTTP Binding given that JAX-RS is a much richer spec. I'd vote for dropping it completely for 2.3 given that various new contributions are expected though still maintaining it in 2.2 fixes. 

Now about the list response :

<ns1:getUsersResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>test@test.com</email>
    <ID>2003</ID>
    <name>User Test One</name>
    <username>userTest1</username>
  </return>
  <return>
    <email>user2@mail.com</email>
    <ID>2002</ID>
    <name>user2 user2</name>
    <username>user2</username>
  </return>
</ns1:getUsersResponse>

May be we should do in JAX-RS something like 

<users xmlns="namespace used by user or package name derived">
  <user>
    <email>test@test.com</email>
    <ID>2003</ID>
    <name>User Test One</name>
    <username>userTest1</username>
  </user>
  <user>
    <email>user2@mail.com</email>
    <ID>2002</ID>
    <name>user2 user2</name>
    <username>user2</username>
  </user>
</users> 

And also introduce some annotations which will give a hint to the runtime on how to customize the wrapping of the list

Cheers, Sergey



-----Original Message-----
From: Gabriel Guardincerri [mailto:gguardin@gmail.com] 
Sent: 16 June 2009 19:37
To: users@cxf.apache.org
Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Hi Sergey,

>
> So what difference in formats is there when you try to switch to JAX-RS (with JAXB 2.1 being the default provider) ? When you switch, do you issues with all the XML samples you posted or is it with PUT only ?

When I switch to JAX-RS with it's default provider I have problems
with all the methods that are in the XML samples. But for PUT or POST
I'm getting a java error, so it may be the qualified namespace that
Daniel mention, I trying to fix and test it again.

On the other side there are differences with GET requests.

For the service "Get User", I get:

Request:

GET http://localhost:8080/rpc/rest/userService/users/user1

Responses:

With HTTP-binding in 2.0.x:

<ns1:getUserByUsernameResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
  </return>
</ns1:getUserByUsernameResponse>

With JAX-RS with its default provider in 2.2.2:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<User>
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
</User>

And for service "Get Users"

Request

GET http://localhost:8080/rpc/rest/userService/users

Responses:

With HTTP-binding in 2.0.x:

<ns1:getUsersResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>test@test.com</email>
    <ID>2003</ID>
    <name>User Test One</name>
    <username>userTest1</username>
  </return>
  <return>
    <email>user2@mail.com</email>
    <ID>2002</ID>
    <name>user2 user2</name>
    <username>user2</username>
  </return>
</ns1:getUsersResponse>

With JAX-RS with its default provider in 2.2.2:

".No message body writer found for response class : ArrayList."


> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF interceptors or JAX-RS filters). For ex, you can check if it's PUT and no namespace is there and adapt as needed - let us know please if/when you decide to go this route to make a smoother migration, we can provide some code samples...

Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
they work with HTTP-binding in that version. If we couldn't find a
solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
this route and I'll appreciate code samples :). But for now I just
prefer to see how HTTP-binding fix goes before going this way that
will imply code migration and a fix to the xml messages format issue.

Thank you,

Gabriel

>
>
>
>
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> Sent: 15 June 2009 20:16
> To: users@cxf.apache.org
> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?
>
> Hi Dan and Sergey,
>
>>> The main change between them that MAY affect the XML binding is going from
>>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>>> different and could potentially change things.
>
> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> some new web services that we need to build. But we need to keep
> backward compatibility with the old web services that we have. So the
> best, meaning less effort, option is to have a fix for HTTP-binding in
> version 2.2.2. We are planning to migrate this old services, but not
> now.
>
> The problem is only with URL params. All our GET and DELETE services
> that use some URL param don't work, they always get null values.
>
> For example
>
> For this service
>
> @WebMethod
> @Get
> @HttpResource(location = "/users/{username}")
> WSUser getUserByUsername(@WebParam(name = "username")String username)
> throws UserNotFoundException;
>
> Using this request
>
> GET http://localhost:8080/rpc/rest/userService/users/user1
>
> It doesn't work. The username param has a null value. Is there a way
> to get a patch for that?
>
>> It is interesting. It would be helpful if Gabriel could post two sample XML
>> instances, one showing what the clients are currently getting and what they
>> would get if CXF 2.2.2 were used, we can proceed from there...
>
> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> same XML, the problem is what I mention above, that some methods don't
> get params. So we were thinking on migrating them to JAX-RS to make it
> work, but we need to configure it to use the same XML messages format
> that we  have for HTTP-binding. I'm attaching some xml samples
> request/response and the interface with the annotations. Sorry that my
> first post wasn't a clear.
>
> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> instead of migrating our old stuff. We are planning to migrate them
> since it was deprecated, but if possible not for our next version, we
> are short of time for this release and this problem was unexpected.
>
> Thanks in advance,
>
> Gabriel
>
> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> wrote:
>> Hi Dan,
>>
>>
>>
>>>
>>> Sergey,
>>>
>>
>>
>>>
>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>>> root element things.   I'm wondering if that may have affected this or not.
>>>
>>
>> possibly...
>>
>> thanks, Sergey
>>
>>>
>>> Dan
>>>
>>>
>>>
>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>>
>>>> Hi,
>>>>
>>>> As far as I'm aware no significant changes have been made to the HTTP
>>>> binding recently, I haven't done any work with it for sure. Perhaps
>>>> there've been some cosmetic changes but I'm not aware of them.
>>>>
>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>>> enhancing the JAX-RS runtime.
>>>>
>>>> > The problem is that we need to keep the same XML messages format for
>>>>
>>>> backward compatibility.
>>>>
>>>> Can you please post a sample class annotated with HTTPBinding
>>>> annotations and XML message which is expected by current clients ?
>>>>
>>>> Thanks, Sergey
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>>> Sent: 12 June 2009 20:08
>>>> To: users@cxf.apache.org
>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>>> messages format?
>>>>
>>>>
>>>> Hi,
>>>>
>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>>> 2.0.11,
>>>> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
>>>> do
>>>> not pass params correctly. So we were trying to migrate those services
>>>> to
>>>> JAX-RS. The problem is that we need to keep the same XML messages format
>>>> for
>>>> backward compatibility. We tried with the three data binding providers
>>>> that
>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>>> and
>>>> AegisElementProvider, but none of them have the same XML format for
>>>> messages
>>>> that HTTP-binding has.
>>>>
>>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>>> use
>>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>>> same
>>>> XML messages?
>>>>
>>>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>>>> or
>>>> 2.1.5, it will be the best solution.
>>>>
>>>> Thanks,
>>>>
>>>> Gabriel
>>>
>>> --
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Hi Sergey,

>
> So what difference in formats is there when you try to switch to JAX-RS (with JAXB 2.1 being the default provider) ? When you switch, do you issues with all the XML samples you posted or is it with PUT only ?

When I switch to JAX-RS with it's default provider I have problems
with all the methods that are in the XML samples. But for PUT or POST
I'm getting a java error, so it may be the qualified namespace that
Daniel mention, I trying to fix and test it again.

On the other side there are differences with GET requests.

For the service "Get User", I get:

Request:

GET http://localhost:8080/rpc/rest/userService/users/user1

Responses:

With HTTP-binding in 2.0.x:

<ns1:getUserByUsernameResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
  </return>
</ns1:getUserByUsernameResponse>

With JAX-RS with its default provider in 2.2.2:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<User>
    <email>user1@fsdfsd.com</email>
    <ID>2001</ID>
    <name>user1 user1</name>
    <username>user1</username>
</User>

And for service "Get Users"

Request

GET http://localhost:8080/rpc/rest/userService/users

Responses:

With HTTP-binding in 2.0.x:

<ns1:getUsersResponse
xmlns:ns1="http://jivesoftware.com/clearspace/webservices">
  <return>
    <email>test@test.com</email>
    <ID>2003</ID>
    <name>User Test One</name>
    <username>userTest1</username>
  </return>
  <return>
    <email>user2@mail.com</email>
    <ID>2002</ID>
    <name>user2 user2</name>
    <username>user2</username>
  </return>
</ns1:getUsersResponse>

With JAX-RS with its default provider in 2.2.2:

".No message body writer found for response class : ArrayList."


> As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF interceptors or JAX-RS filters). For ex, you can check if it's PUT and no namespace is there and adapt as needed - let us know please if/when you decide to go this route to make a smoother migration, we can provide some code samples...

Well, PUT services aren't working right now with JAX-RS in 2.2.2, but
they work with HTTP-binding in that version. If we couldn't find a
solution for GET with HTTP-binding in 2.2.2 then yes, I'll need to go
this route and I'll appreciate code samples :). But for now I just
prefer to see how HTTP-binding fix goes before going this way that
will imply code migration and a fix to the xml messages format issue.

Thank you,

Gabriel

>
>
>
>
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> Sent: 15 June 2009 20:16
> To: users@cxf.apache.org
> Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?
>
> Hi Dan and Sergey,
>
>>> The main change between them that MAY affect the XML binding is going from
>>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>>> different and could potentially change things.
>
> Dan, it may be that change. Our code works on 2.0.7, but it doesn't
> work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
> appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
> some new web services that we need to build. But we need to keep
> backward compatibility with the old web services that we have. So the
> best, meaning less effort, option is to have a fix for HTTP-binding in
> version 2.2.2. We are planning to migrate this old services, but not
> now.
>
> The problem is only with URL params. All our GET and DELETE services
> that use some URL param don't work, they always get null values.
>
> For example
>
> For this service
>
> @WebMethod
> @Get
> @HttpResource(location = "/users/{username}")
> WSUser getUserByUsername(@WebParam(name = "username")String username)
> throws UserNotFoundException;
>
> Using this request
>
> GET http://localhost:8080/rpc/rest/userService/users/user1
>
> It doesn't work. The username param has a null value. Is there a way
> to get a patch for that?
>
>> It is interesting. It would be helpful if Gabriel could post two sample XML
>> instances, one showing what the clients are currently getting and what they
>> would get if CXF 2.2.2 were used, we can proceed from there...
>
> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
> same XML, the problem is what I mention above, that some methods don't
> get params. So we were thinking on migrating them to JAX-RS to make it
> work, but we need to configure it to use the same XML messages format
> that we  have for HTTP-binding. I'm attaching some xml samples
> request/response and the interface with the annotations. Sorry that my
> first post wasn't a clear.
>
> Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
> instead of migrating our old stuff. We are planning to migrate them
> since it was deprecated, but if possible not for our next version, we
> are short of time for this release and this problem was unexpected.
>
> Thanks in advance,
>
> Gabriel
>
> On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> wrote:
>> Hi Dan,
>>
>>
>>
>>>
>>> Sergey,
>>>
>>
>>
>>>
>>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>>> root element things.   I'm wondering if that may have affected this or not.
>>>
>>
>> possibly...
>>
>> thanks, Sergey
>>
>>>
>>> Dan
>>>
>>>
>>>
>>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>>
>>>> Hi,
>>>>
>>>> As far as I'm aware no significant changes have been made to the HTTP
>>>> binding recently, I haven't done any work with it for sure. Perhaps
>>>> there've been some cosmetic changes but I'm not aware of them.
>>>>
>>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>>> enhancing the JAX-RS runtime.
>>>>
>>>> > The problem is that we need to keep the same XML messages format for
>>>>
>>>> backward compatibility.
>>>>
>>>> Can you please post a sample class annotated with HTTPBinding
>>>> annotations and XML message which is expected by current clients ?
>>>>
>>>> Thanks, Sergey
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>>> Sent: 12 June 2009 20:08
>>>> To: users@cxf.apache.org
>>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>>> messages format?
>>>>
>>>>
>>>> Hi,
>>>>
>>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>>> 2.0.11,
>>>> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
>>>> do
>>>> not pass params correctly. So we were trying to migrate those services
>>>> to
>>>> JAX-RS. The problem is that we need to keep the same XML messages format
>>>> for
>>>> backward compatibility. We tried with the three data binding providers
>>>> that
>>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>>> and
>>>> AegisElementProvider, but none of them have the same XML format for
>>>> messages
>>>> that HTTP-binding has.
>>>>
>>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>>> use
>>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>>> same
>>>> XML messages?
>>>>
>>>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>>>> or
>>>> 2.1.5, it will be the best solution.
>>>>
>>>> Thanks,
>>>>
>>>> Gabriel
>>>
>>> --
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>
>

RE: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabriel

Hopefully what Dan suggested around fixing IRIDecoderHelper should work for you for a moment.

In meantime, I'd like to clarify few things.  

> Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
same XML, the problem is what I mention above, that some methods don't
get params.


So what difference in formats is there when you try to switch to JAX-RS (with JAXB 2.1 being the default provider) ? When you switch, do you issues with all the XML samples you posted or is it with PUT only ? As Dan said, you can register a Stax XmlStreamReader or Writer (in CXF interceptors or JAX-RS filters). For ex, you can check if it's PUT and no namespace is there and adapt as needed - let us know please if/when you decide to go this route to make a smoother migration, we can provide some code samples...

Cheers, Sergey


 

-----Original Message-----
From: Gabriel Guardincerri [mailto:gguardin@gmail.com] 
Sent: 15 June 2009 20:16
To: users@cxf.apache.org
Subject: Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Hi Dan and Sergey,

>> The main change between them that MAY affect the XML binding is going from
>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>> different and could potentially change things.

Dan, it may be that change. Our code works on 2.0.7, but it doesn't
work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
some new web services that we need to build. But we need to keep
backward compatibility with the old web services that we have. So the
best, meaning less effort, option is to have a fix for HTTP-binding in
version 2.2.2. We are planning to migrate this old services, but not
now.

The problem is only with URL params. All our GET and DELETE services
that use some URL param don't work, they always get null values.

For example

For this service

@WebMethod
@Get
@HttpResource(location = "/users/{username}")
WSUser getUserByUsername(@WebParam(name = "username")String username)
throws UserNotFoundException;

Using this request

GET http://localhost:8080/rpc/rest/userService/users/user1

It doesn't work. The username param has a null value. Is there a way
to get a patch for that?

> It is interesting. It would be helpful if Gabriel could post two sample XML
> instances, one showing what the clients are currently getting and what they
> would get if CXF 2.2.2 were used, we can proceed from there...

Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
same XML, the problem is what I mention above, that some methods don't
get params. So we were thinking on migrating them to JAX-RS to make it
work, but we need to configure it to use the same XML messages format
that we  have for HTTP-binding. I'm attaching some xml samples
request/response and the interface with the annotations. Sorry that my
first post wasn't a clear.

Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
instead of migrating our old stuff. We are planning to migrate them
since it was deprecated, but if possible not for our next version, we
are short of time for this release and this problem was unexpected.

Thanks in advance,

Gabriel

On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> wrote:
> Hi Dan,
>
>
>
>>
>> Sergey,
>>
>
>
>>
>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> root element things.   I'm wondering if that may have affected this or not.
>>
>
> possibly...
>
> thanks, Sergey
>
>>
>> Dan
>>
>>
>>
>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>
>>> Hi,
>>>
>>> As far as I'm aware no significant changes have been made to the HTTP
>>> binding recently, I haven't done any work with it for sure. Perhaps
>>> there've been some cosmetic changes but I'm not aware of them.
>>>
>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>> enhancing the JAX-RS runtime.
>>>
>>> > The problem is that we need to keep the same XML messages format for
>>>
>>> backward compatibility.
>>>
>>> Can you please post a sample class annotated with HTTPBinding
>>> annotations and XML message which is expected by current clients ?
>>>
>>> Thanks, Sergey
>>>
>>>
>>> -----Original Message-----
>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>> Sent: 12 June 2009 20:08
>>> To: users@cxf.apache.org
>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>> messages format?
>>>
>>>
>>> Hi,
>>>
>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>> 2.0.11,
>>> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
>>> do
>>> not pass params correctly. So we were trying to migrate those services
>>> to
>>> JAX-RS. The problem is that we need to keep the same XML messages format
>>> for
>>> backward compatibility. We tried with the three data binding providers
>>> that
>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>> and
>>> AegisElementProvider, but none of them have the same XML format for
>>> messages
>>> that HTTP-binding has.
>>>
>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>> use
>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>> same
>>> XML messages?
>>>
>>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>>> or
>>> 2.1.5, it will be the best solution.
>>>
>>> Thanks,
>>>
>>> Gabriel
>>
>> --
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Hi Dan and Sergey,

>> The main change between them that MAY affect the XML binding is going from
>> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite
>> different and could potentially change things.

Dan, it may be that change. Our code works on 2.0.7, but it doesn't
work on 2.1.5 nor 2.2.2. If there is a way to fix that I'll really
appreciate it. We want to use the latest version 2.2.2 and JAX-RS for
some new web services that we need to build. But we need to keep
backward compatibility with the old web services that we have. So the
best, meaning less effort, option is to have a fix for HTTP-binding in
version 2.2.2. We are planning to migrate this old services, but not
now.

The problem is only with URL params. All our GET and DELETE services
that use some URL param don't work, they always get null values.

For example

For this service

@WebMethod
@Get
@HttpResource(location = "/users/{username}")
WSUser getUserByUsername(@WebParam(name = "username")String username)
throws UserNotFoundException;

Using this request

GET http://localhost:8080/rpc/rest/userService/users/user1

It doesn't work. The username param has a null value. Is there a way
to get a patch for that?

> It is interesting. It would be helpful if Gabriel could post two sample XML
> instances, one showing what the clients are currently getting and what they
> would get if CXF 2.2.2 were used, we can proceed from there...

Sergey, actually when using HTTP-binding with CXF 2.2.2 we get the
same XML, the problem is what I mention above, that some methods don't
get params. So we were thinking on migrating them to JAX-RS to make it
work, but we need to configure it to use the same XML messages format
that we  have for HTTP-binding. I'm attaching some xml samples
request/response and the interface with the annotations. Sorry that my
first post wasn't a clear.

Anyway, we prefer to just apply a patch to CXF 2.2.2 to make it work,
instead of migrating our old stuff. We are planning to migrate them
since it was deprecated, but if possible not for our next version, we
are short of time for this release and this problem was unexpected.

Thanks in advance,

Gabriel

On Mon, Jun 15, 2009 at 1:12 PM, Sergey Beryozkin<sb...@progress.com> wrote:
> Hi Dan,
>
>
>
>>
>> Sergey,
>>
>
>
>>
>> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the
>> root element things. � I'm wondering if that may have affected this or not.
>>
>
> possibly...
>
> thanks, Sergey
>
>>
>> Dan
>>
>>
>>
>> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>>>
>>> Hi,
>>>
>>> As far as I'm aware no significant changes have been made to the HTTP
>>> binding recently, I haven't done any work with it for sure. Perhaps
>>> there've been some cosmetic changes but I'm not aware of them.
>>>
>>> We've agreed to deprecate the HTTP binding as all the focus now is on
>>> enhancing the JAX-RS runtime.
>>>
>>> > The problem is that we need to keep the same XML messages format for
>>>
>>> backward compatibility.
>>>
>>> Can you please post a sample class annotated with HTTPBinding
>>> annotations and XML message which is expected by current clients ?
>>>
>>> Thanks, Sergey
>>>
>>>
>>> -----Original Message-----
>>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>>> Sent: 12 June 2009 20:08
>>> To: users@cxf.apache.org
>>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>>> messages format?
>>>
>>>
>>> Hi,
>>>
>>> We have a lot of WS that were implemented using HTTP-binding of CXF
>>> 2.0.11,
>>> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
>>> do
>>> not pass params correctly. So we were trying to migrate those services
>>> to
>>> JAX-RS. The problem is that we need to keep the same XML messages format
>>> for
>>> backward compatibility. We tried with the three data binding providers
>>> that
>>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>>> and
>>> AegisElementProvider, but none of them have the same XML format for
>>> messages
>>> that HTTP-binding has.
>>>
>>> Is there a way to do so? I mean, to implement services with JAX-RS and
>>> use
>>> the same XML data binding that has HTTP-binding? Or a way to build the
>>> same
>>> XML messages?
>>>
>>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>>> or
>>> 2.1.5, it will be the best solution.
>>>
>>> Thanks,
>>>
>>> Gabriel
>>
>> --
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Dan,



> 
> Sergey,
> 
> The main change between them that MAY affect the XML binding is going from 
> JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite 
> different and could potentially change things.    

It is interesting. It would be helpful if Gabriel could post two sample XML instances, 
one showing what the clients are currently getting and what they would get if CXF 2.2.2 were used, we can proceed from there...

> 
> I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the root 
> element things.   I'm wondering if that may have affected this or not.  

possibly...

thanks, Sergey

> 
> Dan
> 
> 
> 
> On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
>> Hi,
>>
>> As far as I'm aware no significant changes have been made to the HTTP
>> binding recently, I haven't done any work with it for sure. Perhaps
>> there've been some cosmetic changes but I'm not aware of them.
>>
>> We've agreed to deprecate the HTTP binding as all the focus now is on
>> enhancing the JAX-RS runtime.
>>
>> > The problem is that we need to keep the same XML messages format for
>>
>> backward compatibility.
>>
>> Can you please post a sample class annotated with HTTPBinding
>> annotations and XML message which is expected by current clients ?
>>
>> Thanks, Sergey
>>
>>
>> -----Original Message-----
>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> Sent: 12 June 2009 20:08
>> To: users@cxf.apache.org
>> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
>> messages format?
>>
>>
>> Hi,
>>
>> We have a lot of WS that were implemented using HTTP-binding of CXF
>> 2.0.11,
>> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
>> do
>> not pass params correctly. So we were trying to migrate those services
>> to
>> JAX-RS. The problem is that we need to keep the same XML messages format
>> for
>> backward compatibility. We tried with the three data binding providers
>> that
>> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
>> and
>> AegisElementProvider, but none of them have the same XML format for
>> messages
>> that HTTP-binding has.
>>
>> Is there a way to do so? I mean, to implement services with JAX-RS and
>> use
>> the same XML data binding that has HTTP-binding? Or a way to build the
>> same
>> XML messages?
>>
>> Of course, if there is a way to make HTTP-binding work in version 2.2.2
>> or
>> 2.1.5, it will be the best solution.
>>
>> Thanks,
>>
>> Gabriel
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog

Re: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Daniel Kulp <dk...@apache.org>.
Sergey,

The main change between them that MAY affect the XML binding is going from 
JAXB 2.0.x to JAXB 2.1.x.    The generated code from xjc can be quite 
different and could potentially change things.    

I know a bug was fixed in the HTTP binding for 2.2.2 in regards to the root 
element things.   I'm wondering if that may have affected this or not.  

Dan



On Sun June 14 2009 3:47:26 pm Sergey Beryozkin wrote:
> Hi,
>
> As far as I'm aware no significant changes have been made to the HTTP
> binding recently, I haven't done any work with it for sure. Perhaps
> there've been some cosmetic changes but I'm not aware of them.
>
> We've agreed to deprecate the HTTP binding as all the focus now is on
> enhancing the JAX-RS runtime.
>
> > The problem is that we need to keep the same XML messages format for
>
> backward compatibility.
>
> Can you please post a sample class annotated with HTTPBinding
> annotations and XML message which is expected by current clients ?
>
> Thanks, Sergey
>
>
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
> Sent: 12 June 2009 20:08
> To: users@cxf.apache.org
> Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
> messages format?
>
>
> Hi,
>
> We have a lot of WS that were implemented using HTTP-binding of CXF
> 2.0.11,
> but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
> do
> not pass params correctly. So we were trying to migrate those services
> to
> JAX-RS. The problem is that we need to keep the same XML messages format
> for
> backward compatibility. We tried with the three data binding providers
> that
> are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
> and
> AegisElementProvider, but none of them have the same XML format for
> messages
> that HTTP-binding has.
>
> Is there a way to do so? I mean, to implement services with JAX-RS and
> use
> the same XML data binding that has HTTP-binding? Or a way to build the
> same
> XML messages?
>
> Of course, if there is a way to make HTTP-binding work in version 2.2.2
> or
> 2.1.5, it will be the best solution.
>
> Thanks,
>
> Gabriel

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

RE: How to migrate REST HTTP-binding to JAX-RS and keep the xml messages format?

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

As far as I'm aware no significant changes have been made to the HTTP
binding recently, I haven't done any work with it for sure. Perhaps
there've been some cosmetic changes but I'm not aware of them.

We've agreed to deprecate the HTTP binding as all the focus now is on
enhancing the JAX-RS runtime. 


> The problem is that we need to keep the same XML messages format for
backward compatibility.

Can you please post a sample class annotated with HTTPBinding
annotations and XML message which is expected by current clients ?

Thanks, Sergey
 

-----Original Message-----
From: Gabriel Guardincerri [mailto:gguardin@gmail.com] 
Sent: 12 June 2009 20:08
To: users@cxf.apache.org
Subject: How to migrate REST HTTP-binding to JAX-RS and keep the xml
messages format?


Hi, 

We have a lot of WS that were implemented using HTTP-binding of CXF
2.0.11,
but when we tried to migrate CXF to 2.2.2 we found out that HTTP-binding
do
not pass params correctly. So we were trying to migrate those services
to
JAX-RS. The problem is that we need to keep the same XML messages format
for
backward compatibility. We tried with the three data binding providers
that
are in the jaxrs package XMLBeansElementProvider, JAXBElementProvider
and
AegisElementProvider, but none of them have the same XML format for
messages
that HTTP-binding has.

Is there a way to do so? I mean, to implement services with JAX-RS and
use
the same XML data binding that has HTTP-binding? Or a way to build the
same
XML messages?

Of course, if there is a way to make HTTP-binding work in version 2.2.2
or
2.1.5, it will be the best solution.

Thanks,

Gabriel
-- 
View this message in context:
http://www.nabble.com/How-to-migrate-REST-HTTP-binding-to-JAX-RS-and-kee
p-the-xml-messages-format--tp24004576p24004576.html
Sent from the cxf-user mailing list archive at Nabble.com.