You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Soti, Dheeraj" <ds...@harris.com> on 2005/04/05 21:04:36 UTC
Doubts regarding cyclic loops and inheritance
Hi,
Sending this again to all of you.
I have class A that contains an array of type B elements. class B keeps a
reference to A. This will definitely create a loop when Axis will try to
serialize it because while serializing B it'll try to serialize A and then B and
so on. Dino replied to my earlier mail and suggested that reference can be kept
through an id of A as well. If I do that then it becomes pretty easy and there
is no problem of looping but the downside is that sometimes consumer might have
to give a different call to obtain the instance of class A using the id because
some elements of the array of type B might point to another instance of class A.
I hope I am not confusing you. See below:
Instance1 of A
...field1
...field2
...Array of Instances of B
Elements of Array of Instances of B are:
--Instance1 of B (points to Instance1 of A)
--Instance2 of B (points to some other instance of A)
Q1. I am wondering what is the best practice here:
--sacrifice the ease of loading the full object graph in favor of simple wsdl
and simple serialization & de-serialization as that is the bottleneck in terms
of performance.
--or do something else to workaround this issue like create another complex
element for A again which doesn't have further levels and use that for
reference.
Q2. I have a class that contains another class as a field for which there can be
multiple implementations.
class ContentContainer contains multiple ContentElements and there are multiple
implementations of the latter (see below). How should I write my complex element
in this case. As Anne also suggests that we should not treat web services as
distributed object system so I don't want to use inheritance. One way can be to
create a complex element that contains fields from all possible implementations
of ContentElement and use that as a member of ContentContainer. Based on the
fields set by the client I should create a specific instance at the
implementation side. Any suggestion on this?
ContentContainer-----contains one or more ---------------->ContentElement
|
|
----------------------------------------------------------
|
|
Element Type1
Element Type 2
Thanks
Dheeraj Soti
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://services.hrs.harris.com/
<http://services.hrs.harris.com/> "
xmlns:apachesoap="http://xml.apache.org/xml-soap
<http://xml.apache.org/xml-soap> "
xmlns:impl="http://services.hrs.harris.com/ <http://services.hrs.harris.com/>
"
xmlns:intf="http://services.hrs.harris.com/ <http://services.hrs.harris.com/>
"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/
<http://schemas.xmlsoap.org/soap/encoding/> "
xmlns:tns1="http://services.hrs.harris.com/ <http://services.hrs.harris.com/>
"
xmlns:content="http://content.services.hrs.harris.com/
<http://content.services.hrs.harris.com/> "
xmlns:media="http://media.services.hrs.harris.com/
<http://media.services.hrs.harris.com/> "
xmlns:device="http://device.services.hrs.harris.com/
<http://device.services.hrs.harris.com/> "
xmlns:storage="http://storage.services.hrs.harris.com/
<http://storage.services.hrs.harris.com/> "
xmlns:timecode="http://timecode.services.hrs.harris.com/
<http://timecode.services.hrs.harris.com/> "
xmlns:config="http://config.services.hrs.harris.com/
<http://config.services.hrs.harris.com/> "
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/
<http://schemas.xmlsoap.org/wsdl/> "
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/
<http://schemas.xmlsoap.org/wsdl/soap/> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema>
">
<!--WSDL created by Apache Axis version: 1.2RC2 Built on Nov 16, 2004 (12:19:44
EST)-->
<wsdl:types>
<schema targetNamespace="http://timecode.services.hrs.harris.com/
<http://timecode.services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<complexType name="ImmutableFrameTime">
<sequence>
<element name="frameCount" type="xsd:long"/>
<element name="frameRate" type="xsd:double" />
</sequence>
</complexType>
<complexType name="TimeCodeImpl">
<sequence>
<element name="frameTime" nillable="true"
type="timecode:ImmutableFrameTime"/>
</sequence>
</complexType>
</schema>
<schema targetNamespace="http://media.services.hrs.harris.com/
<http://media.services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<complexType name="Media">
<sequence>
<element name="id" type="xsd:long"/>
<element name="storageFile" type="storage:StorageFile"/>
<element name="som" type="timecode:ImmutableFrameTime"/>
<element name="resolution" type="xsd:int"/>
</sequence>
</complexType>
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://content.services.hrs.harris.com/
<http://content.services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<complexType name="MultiSegment">
<sequence>
<element name="id" type="xsd:long"/>
<element name="name" type="xsd:string"/>
<element name="description" nillable="true" type="xsd:string"/>
<element name="som" nillable="true"
type="timecode:ImmutableFrameTime"/>
<element name="duration" nillable="true"
type="timecode:ImmutableFrameTime"/>
<element name="parentContainer"
type="content:ContentContainer"/>
<element name="segmentIndex" nillable="true" type="xsd:int"/>
<element name="contentMetadata" type="content:ProgramContent"/>
</sequence>
</complexType>
<complexType name="ContentContainer">
<sequence>
<element name="contentMetadata" type="content:ProgramContent"/>
<element name="id" type="xsd:long"/>
<element name="name" type="xsd:string"/>
<element name="description" nillable="true" type="xsd:string"/>
<!--element name="mediaList" nillable="true"
type="impl:ArrayOf_Media" /-->
<element name="multiSegments" nillable="true"
type="impl:ArrayOf_MultiSegment" />
<element name="directOriginator"
type="content:ContentContainer"/>
</sequence>
</complexType>
<complexType name="ProgramContent">
<sequence>
<element name="id" type="xsd:long"/>
<element name="title" nillable="true" type="soapenc:string"/>
<element name="description" nillable="true" type="xsd:string"/>
<element name="estimatedDuration" nillable="true"
type="timecode:ImmutableFrameTime"/>
<element name="houseId" nillable="true" type="xsd:string"/>
<element name="episodeNumber" nillable="true" deafult=""
type="xsd:string"/>
<element name="umid" nillable="true" type="xsd:string"
default=""/>
<element name="episodeTitle" nillable="true" type="xsd:string"
default=""/>
<element name="contentRealizations" nillable="true"
type="impl:ArrayOf_content_ContentContainer"/>
<element name="numberProgramSegments" nillable="true"
default="1" type="xsd:int"/>
</sequence>
</complexType>
</schema>
<schema targetNamespace="http://device.services.hrs.harris.com/
<http://device.services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<complexType name="DeviceVendor">
<sequence>
<element name="name" type="xsd:string"/>
<element name="storageHandlerId" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://services.hrs.harris.com/
<http://services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/
<http://schemas.xmlsoap.org/soap/encoding/> " />
<complexType name="ArrayOf_MultiSegment">
<sequence>
<element name="segments" maxOccurs="unbounded" nillable="true"
type="content:MultiSegment" />
</sequence>
</complexType>
<complexType name="ArrayOf_content_ContentContainer">
<sequence>
<element name="containers" maxOccurs="unbounded" nillable="true"
type="content:ContentContainer" />
</sequence>
</complexType>
<complexType name="ArrayOf_Media">
<sequence>
<element name="medias" maxOccurs="unbounded" nillable="true"
type="media:Media" />
</sequence>
</complexType>
<complexType name="ArrayOf_StorageVolume">
<sequence>
<element name="storages" maxOccurs="unbounded" nillable="true"
type="storage:StorageVolume" />
</sequence>
</complexType>
<!--The following four elements have to be defined for doc/literal
wrapped-->
<complexType name="createContentInput">
<sequence>
<element name="arg1" type="content:ProgramContent"/>
</sequence>
</complexType>
<complexType name="createContentOutput">
<sequence>
<element name="status" type="xsd:boolean"/>
</sequence>
</complexType>
<element name="createContent" type="impl:createContentInput"/>
<element name="createContentResponse" type="impl:createContentOutput"/>
<!--The above four elements have to be defined for doc/literal
wrapped-->
</schema>
<schema targetNamespace="http://storage.services.hrs.harris.com/
<http://storage.services.hrs.harris.com/> "
xmlns="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> ">
<complexType name="StorageFile">
<sequence>
<element name="id" type="xsd:long"/>
<element name="pathName" type="xsd:string"/>
<element name="volume" type="storage:StorageVolume"/>
</sequence>
</complexType>
<complexType name="StorageDevice">
<sequence>
<element name="id" type="xsd:long"/>
<element name="name" type="xsd:string"/>
<element name="volumes" type="impl:ArrayOf_StorageVolume"/>
<element name="deviceVendorName" type="xsd:string"/>
<element name="iPAddress" type="xsd:string"/>
<element name="protocol" type="xsd:string"/>
<element name="username" type="xsd:string"/>
<element name="password" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="StorageVolume">
<sequence>
<element name="id" type="xsd:long"/>
<element name="storageDevice" type="storage:StorageDevice"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="createContentRequest">
<wsdl:part name="in0" element='impl:createContent'/>
</wsdl:message>
<wsdl:message name="createContentResponse">
<wsdl:part name="createContentReturn"
element='impl:createContentResponse'/>
</wsdl:message>
<wsdl:portType name="ContentServiceWS">
<wsdl:operation name="createContent" parameterOrder="in0">
<wsdl:input message="impl:createContentRequest"
name="createContentRequest"/>
<wsdl:output message="impl:createContentResponse"
name="createContentResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ContentServiceSoapBinding" type="impl:ContentServiceWS">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http
<http://schemas.xmlsoap.org/soap/http> " style="document" />
<wsdl:operation name="createContent">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="createContentRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createContentResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HRSWebService">
<wsdl:port binding="impl:ContentServiceSoapBinding"
name="ContentServiceWS">
<wsdlsoap:address
location="http://localhost:8080/hrsApp/services/ContentServiceWS
<http://localhost:8080/hrsApp/services/ContentServiceWS> "/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>