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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: bi-directional relationships
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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: bi-directional relationships
Chris, for advanced JAXB questions, you might just want to go ahead and ask on the Sun forum[1]. We use their JAXB, and the JAXB specialists tend to congregate on that site. Regards, Glen [1] http://forums.java.net/jive/forum.jspa?forumID=46 Am Freitag, den 11.04.2008, 14:33 -0700 schrieb [EMAIL PROTECTED]: 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553
bi-directional relationships
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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553
Re: bi-directional relationships
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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553
Re: bi-directional relationships
Glen, Thanks ever so much! This is exactly what I needed to further my understanding. You Da Man!!! Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Glen Mazza [EMAIL PROTECTED] 04/10/2008 06:13 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships 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 [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553