You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Kessel, Christopher" <ck...@transunion.com> on 2009/11/20 19:19:02 UTC

Hooking into CXF's XML<->Object handling?

I've got a JAXWS web service setup, much like the CXF tutorials. It's
wonderful. I have some annotated classes (XmlElement, XmlAttributes,
etc). I create the Java object on the client, call the client proxy, and
poof on the server I have the resulting Java object to use in the
invoked web service method. Life is good :).

However, I need to support a straight xml over http interface as well as
SOAP. The object XML is the same inside the soap message as the object
XML I'll be receiving in my straight xml over http support. I'd like to
hook into whatever code CXF is using to do the Java<->XML translation.
I've been looking at the JAXB stuff and it's way more complicated. It
wants me to create an ObjectFactory, create marshal() and unmarshal()
methods, etc. 

It seems like there must be a simpler way. CXF is doing this all for me
beautifully right now within the web service call so some subportion of
that is already doing the XML-to-object translation work. Is there a way
I can make us of that rather than going down the pure JAXB route which,
frankly, looks painful.

Thanks,
Chris
 

Re: Hooking into CXF's XML<->Object handling?

Posted by John Klassa <jo...@klassa.com>.
Chris,

Here's some sample code that may help.  It uses JAXB directly, to generate an XML representation of your object.  In this case, the "outbound message" is defined via an XML schema (.xsd) that is turned into a Java object via xjc.sh.  Basically, you populate the resulting Java object with information, and then use the attached code to marshall it into XML.  What I sent should help you figure out what's important, and what you can ignore (for now).

(I realize you asked for a way to hook into what CXF does, but thought this may help as an alternative, if you can't get the "do it like CXF does it" route to work.)

HTH,
JK


Re: Hooking into CXF's XML<->Object handling?

Posted by Benson Margulies <bi...@gmail.com>.
We have a plain HTTP binding, which I'm not an expert on.

On Fri, Nov 20, 2009 at 1:19 PM, Kessel, Christopher <ckessel@transunion.com
> wrote:

> I've got a JAXWS web service setup, much like the CXF tutorials. It's
> wonderful. I have some annotated classes (XmlElement, XmlAttributes,
> etc). I create the Java object on the client, call the client proxy, and
> poof on the server I have the resulting Java object to use in the
> invoked web service method. Life is good :).
>
> However, I need to support a straight xml over http interface as well as
> SOAP. The object XML is the same inside the soap message as the object
> XML I'll be receiving in my straight xml over http support. I'd like to
> hook into whatever code CXF is using to do the Java<->XML translation.
> I've been looking at the JAXB stuff and it's way more complicated. It
> wants me to create an ObjectFactory, create marshal() and unmarshal()
> methods, etc.
>
> It seems like there must be a simpler way. CXF is doing this all for me
> beautifully right now within the web service call so some subportion of
> that is already doing the XML-to-object translation work. Is there a way
> I can make us of that rather than going down the pure JAXB route which,
> frankly, looks painful.
>
> Thanks,
> Chris
>
>

Re: Hooking into CXF's XML<->Object handling?

Posted by Daniel Kulp <dk...@apache.org>.
You want the XML binding in CXF.  See:
http://cxf.apache.org/docs/pure-xml.html

It sounds like you are doing java first.  For the jaxws:endpoint config, add 
the bindingUri attribute set to 
http://cxf.apache.org/bindings/xformat

I THINK that should do it.  

Dan


On Fri November 20 2009 1:19:02 pm Kessel, Christopher wrote:
> I've got a JAXWS web service setup, much like the CXF tutorials. It's
> wonderful. I have some annotated classes (XmlElement, XmlAttributes,
> etc). I create the Java object on the client, call the client proxy, and
> poof on the server I have the resulting Java object to use in the
> invoked web service method. Life is good :).
> 
> However, I need to support a straight xml over http interface as well as
> SOAP. The object XML is the same inside the soap message as the object
> XML I'll be receiving in my straight xml over http support. I'd like to
> hook into whatever code CXF is using to do the Java<->XML translation.
> I've been looking at the JAXB stuff and it's way more complicated. It
> wants me to create an ObjectFactory, create marshal() and unmarshal()
> methods, etc.
> 
> It seems like there must be a simpler way. CXF is doing this all for me
> beautifully right now within the web service call so some subportion of
> that is already doing the XML-to-object translation work. Is there a way
> I can make us of that rather than going down the pure JAXB route which,
> frankly, looks painful.
> 
> Thanks,
> Chris
> 

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