java - SOAP webservice: Multiple references to the same object in SOAP result -


i'm building soap service used in jboss 7.1. until i'm using annotations , no xml files of generated files. both server , client work fine pojo's.

however, have objects referring other objects i'd part of soap response. use @xmlelement annotation, when object referenced multiple times, included multiple times well. try work around using @xmlidref annotation, results in null object on client side.

i've create stand-alone example wheel objects referencing bike belong to, , service retrieve wheels (this short, incomplete code. see below link actual code):

@webservice public interface iwheelservice {     collection<wheel> getallwheels(); }  public class wheel extends xmlentity {     private string type;     private bike bike;      public wheel(bike bike, string type) {         this.bike = bike;         this.type = type;     }      @xmlidref     public bike getbike() {         return bike;     }      @xmlelement     public string gettype() {         return type;     } }  public class bike extends xmlentity {     private string color;      public bike(string color) {         this.color = color;     }      public string getcolor() {         return color;     } }  public abstract class xmlentity implements serializable {     public static int idgenerator = 0;     private int id = idgenerator++;      @xmltransient     public int getid() {         return id;     }      @xmlid     @xmlattribute(name = "id")     @transient     public string getxmlid() {         return string.format("%s:%d", this.getclass().getsimplename(), this.id);     } } 

the full code example available here.

below soap response, containing right bike-id wheels, not actual bike-elements. wheel.getbike() return null on client.

is there annotation make jax-ws send related objects? or @ least obtain bike-ids on client can retrieve them second soap-request?

<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">     <s:body>         <ns2:getallwheelsresponse xmlns:ns2="http://demo/">             <return id="wheel:1">                 <bike>bike:0</bike>                 <type>slick</type>             </return>             <return id="wheel:2">                 <bike>bike:0</bike>                 <type>spike</type>             </return>         </ns2:getallwheelsresponse>     </s:body> </s:envelope> 


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -