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 Dino Chiesa <di...@microsoft.com> on 2005/04/14 15:56:02 UTC

RE: Getting StackOverflow error while trying to invoke the service

Getting back to older threads .. . .
 
For Q1, 
I would use a custom serializer. 
You can just fix up the back-references in application code. at runtime.

For example, introduce a method like 
  Volume.getDevice() 
and that method does a scan on the device table, for a device with the
given ID.  you can then store the reference to this device in your
object.  (But don't serialize it) .    This is all pretty easy in .NET,
and also doable in AXIS with custom serialization.  
 
or move to something like SDO, which does this.  
 
For Q2, I don't know what specifically you are asking but it is possible
for complexTypes to contain other complexTypes. 
This is fully interoperable. 
 
 


________________________________

From: Soti, Dheeraj [mailto:dsoti@harris.com] 
Sent: Monday, April 04, 2005 6:31 PM
To: 'axis-user@ws.apache.org'
Subject: RE: Getting StackOverflow error while trying to invoke the
service


Dino,
 
Thanks for your elaborate reply.
 
 In my case the class A contains an array of type B elements. As you
also noticed that 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. As you said
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
 
 
 
 
 
 
 
-----Original Message-----
From: Dino Chiesa [mailto:dinoch@microsoft.com] 
Sent: Wednesday, March 30, 2005 1:50 AM
To: axis-user@ws.apache.org
Subject: RE: Getting StackOverflow error while trying to invoke the
service



	You can prevent loops by normalizing your data schema. 
	for example, look at the cyclic loop in the storage namespace.
you have devices that contain volumes, and volumes that contain devices.
this schema design in itself is not an error, but it strikes me as a bit
loose.  And the pitfall is:  inserting a cycle into your Java-side data
structures will cause a loop at runtime.  If DeviceA includes VolumeA,
and VolumeA contains DeviceA, sayonara.  I suspect this is what is
happening. 
	 
	if you normalize your data model, you may easily avoid this.
Specify a VolumeId and a DeviceId, for example.  The Device itself can
include a VolumeId, which refers to an externally defined Volume.  Maybe
the Id is a UUID.  Maybe an int. whatever.  This way you have references
to Volumes, not actual volumes.  
	 
	I would use the reference when the relationship is
"isContainedBy  or  belongsTo.    I would use the actual containment
when the relationship between respective types is   "contains".    If
you get my meaning.  If a device contains volumes, then the Volume type
should refer to a DeviceId, rather than containing an actual device.  
	 
	The other spots you identified, where a type contains an array
of itself, or where typeA contains typeB which contains an array of
typeA. . . (your contentContainer types and related).  This is also a
potential source of loops, but again is not an error in schema design.
If you introduce a loop in your object graph at runtime, then AXIS will
loop endlessly trying to serialize it.   If you don't build cycles into
the object graph, then you won't experience the problem.   This area
didn't bother me as much as the device/volume situation, because it
seems there are more obvious scenarios where this sort of type nesting
makes sense.  But if looping is likely, you could apply the same
reference approach here. 
	 
	
	
________________________________

	From: Soti, Dheeraj [mailto:dsoti@harris.com] 
	Sent: Tuesday, March 29, 2005 8:46 PM
	To: 'axis-user@ws.apache.org'
	Subject: Getting StackOverflow error while trying to invoke the
service
	
	

	I do have cyclic loops at some places.  Any idea how to prevent
this? See the WSDL below. I have highlighted the suspected places in
red.

	Thanks 

	Dheeraj 

	<?xml version="1.0" encoding="UTF-8"?> 
	<wsdl:definitions
targetNamespace="http://services.hrs.harris.com/" 
	  xmlns:apachesoap="http://xml.apache.org/xml-soap" 
	  xmlns:impl="http://services.hrs.harris.com/" 
	  xmlns:intf="http://services.hrs.harris.com/" 
	  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
	  xmlns:tns1="http://services.hrs.harris.com/" 
	  xmlns:content="http://content.services.hrs.harris.com/" 
	  xmlns:media="http://media.services.hrs.harris.com/" 
	  xmlns:device="http://device.services.hrs.harris.com/" 
	  xmlns:storage="http://storage.services.hrs.harris.com/" 
	  xmlns:timecode="http://timecode.services.hrs.harris.com/" 
	  xmlns:config="http://config.services.hrs.harris.com/" 
	  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
	  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
	  xmlns:xsd="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/" 
	        xmlns="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/" 
	        xmlns="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/" 
	        xmlns="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/" 
	        xmlns="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/" 
	        xmlns="http://www.w3.org/2001/XMLSchema"> 
	        <import
namespace="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/" 
	        xmlns="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" 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"/> 

	      </wsdl:port> 

	   </wsdl:service> 

	</wsdl:definitions>