cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject Re: bi-directional relationships
Date Fri, 11 Apr 2008 21:33:58 GMT
I've begun to play with this type of implementation, using the @XmlIDREF 
and @XmlAttribute annotations and I've found a few issues.

1) As stated below, your client generated classes have the references to 
parent objects defined as data type Object. (an annoyance but workable)
2) As stated in the documentation: You'd also need to ensure that the 
referenced objects are contained somewhere else (like in the Root class in 
this case), or else Bar objects will never be marshalled. 

This one is difficult. I have a parent class that I return from my 
Services methods that contain all the information associated to the user 
and the request:
UserAcct -> Quote -> SalesResp

When this gets returned to the client the objects are just as the server 
sent them back.  But when I send a child object back over to the server 
all the references to the parents are lost.

Example:  addSalesRep(SalesRepDTO salesRep) {
...

The SalesRep object no longer has the parent Quote. That is because the 
original container no longer exists. I would need to define a new contain 
to be used to hold the object structure. 

I've tried several things to get around this, like placing a 
@XmlRootElement on my SalesRepDTO class on both the server and client 
classes but to no avail. There just doesn't seem to be a way to make this 
work how I would expect it to. The references to the parents are always 
lost when sending the objects from the client to the server.

Any suggestions?

Chris Mathrusse
christopher.mathrusse@sybase.com
Sybase, Inc
One Sybase Drive
Dublin, CA 94568
(925) 236-5553



Christopher.Mathrusse@sybase.com 
04/11/2008 12:50 PM
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc

Subject
Re: bi-directional relationships






I've started playing with this and it seems to work correctly. (More 
testing needed) But one issue I came across was in the generated Client 
objects. 

My server side object looks as follows:

public class QuoteDTO {
@XmlAttribute @XmlIDREF
        protected CustomerDTO customer;


But my generated Client object looks as follows:
public class QuoteDTO {
    @XmlAttribute
    @XmlIDREF
    protected Object customer;


So now when my client attempts to access the customer the specific data 
type is lost. Is there any work around for this?

Thanks...

Chris Mathrusse
christopher.mathrusse@sybase.com
Sybase, Inc
One Sybase Drive
Dublin, CA 94568
(925) 236-5553



Daniel Kulp <dkulp@apache.org> 
04/11/2008 12:44 PM
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc

Subject
Re: bi-directional relationships







Wow.   This is neet.   I didn't know about this one at all.  I honestly 
though JAXB wouldn't do it.   I learned something today.  :-)

Thanks Glen!
Dan


On Thursday 10 April 2008, Glen Mazza wrote:
> Here you go:
> https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html
>
> Glen
>
> Am Donnerstag, den 10.04.2008, 16:12 -0700 schrieb
>
> Christopher.Mathrusse@sybase.com:
> > I'm using CXF 2.0.5. My Web Service is as follows:
> > @WebService(endpointInterface = "com.sybase.it.quoting.QuoteBroker",
> > portName = "QuoteBroker", targetNamespace =
> > "http://quoting.it.sybase.com", name = "QuoteBroker")
> > @SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, style =
> > Style.DOCUMENT, use = Use.LITERAL)
> > @Service("quoteBroker")
> > public abstract class QuoteBrokerImpl implements QuoteBroker ...
> >
> >
> > I am returning DTO's from my web service that are populated with
> > data from my Hibernate objects. The problem that I am running into
> > now is the following exception:
> >
> > INFO: Interceptor has thrown exception, unwinding now
> > org.apache.cxf.interceptor.Fault: Marshalling Error: A cycle is
> > detected in the object graph. This will cause infinitely deep XML:
> > com.sybase.it.quoting.QuoteDTO@1355ef9 ->
> > com.sybase.it.quoting.QuoteLineitemDTO@1a729c1 ->
> > com.sybase.it.quoting.QuoteDTO@1355ef9
> >
> > This is due to the relationship that is defined.  Quote ->
> > QuoteLineItem -> Quote
> > Because the relationship is bi-directional I am seeing this
> > exception occurring. The Web Service is a replacement of an old Axis
> > 1.0 RPC/Encoded web service. Now that I have it running with CXF
> > using
> > Document/Literal/Wrapped I am seeing this issue.
> >
> > How have others resolved/worked around this issue?
> >
> > Thanks...
> >
> > Chris Mathrusse
> > christopher.mathrusse@sybase.com
> > Sybase, Inc
> > One Sybase Drive
> > Dublin, CA 94568
> > (925) 236-5553



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message