Note that this WSDL is not valid. Because this WSDL is document style, the <Hemmings:body> definitions must not contain namespace attributes.

As a general rule, I discourage you from substituting derived types in SOAP messages because it can cause significant interop challenges.

In this particular example, it's simpler (and more extensible) to just add another element to the VehicleType type to indicate the type of vehicle.

Anne

On 6/25/06, Martin Gainty <[EMAIL PROTECTED]> wrote:
Joshua/Mr Clinton
 
Here is a SOAP service which uses the aforementioned 'Vehicle' BaseType, 'Car' DerivedType and Motorcycle DerivedType for determining BlueBook
The Initial Implementation goes to 'localhost'
Production Implementation goes to Hemmings Motor News !!!

Hope this works for ya..

Martin --
 
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 xmlns:Hemmings=" http://schemas.xmlsoaporg/wsdl/Hemmings/"
 xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/"
 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/ "
 xmlns:ns1="http://testexamples/xsd"
 xmlns:ns=" http://BlueBookValue.ve.recursionsw.com/types"
 targetNamespace=" http://BlueBookValue.ve.recursionsw.com/types">
 
<wsdl:types>
<xs:schema
 xmlns:xs=" http://www.w3.org/2001/XMLSchema"
 xmlns:ns="http://testexamples/xsd"
 targetNamespace=" http://testexamples/xsd"
 elementFormDefault="unqualified" attributeFormDefault="unqualified">
 
<xs:complexType name="VehicleDescription">
  <xs:sequence>
 <xs:element type="xs:int" name="Body" />
 <xs:element type="xs:int" name="Engine" />
 <xs:element type="xs:int" name="Transmission" />
 <xs:element type="xs:int" name="Mileage" />
  </xs:sequence>
</xs:complexType>
 
<xs:element name="calculateBlueBookValue">
 <xs:complexType>
  <xs:sequence>
   <xs:element type="ns:VehicleDescription" name="param0" />
  </xs:sequence>
 </xs:complexType>
</xs:element>
 
<xs:element name="calculateBlueBookValueResponse">
 <xs:complexType>
  <xs:sequence>
   <xs:element type="xs:int" name="return" />
  </xs:sequence>
 </xs:complexType>
</xs:element>
 
<!-- base type -->
<xs:complexType name="VehicleType">
  <xs:sequence>
    <xs:element minOccurs="1" maxOccurs="1" name="Make" type="xs:string" />
    <xs:element minOccurs="1" maxOccurs="1" name="Model" type="xs:string" />
    <xs:element minOccurs="1" maxOccurs="1" name="Year" type="xs:int" />
  </xs:sequence>
</xs:complexType>
 
<!-- 1st derived type -->
<xs:complexType name="Motorcycle">
  <xs:complexContent mixed="false">
    <xs:extension base="ns:VehicleType"></xs:extension>
  </xs:complexContent>
</xs:complexType>
 
<!-- 2nd derrived base type -->
<xs:complexType name="Car">
  <xs:complexContent mixed="false">
    <xs:extension base="ns:VehicleType">
    </xs:extension>
  </xs:complexContent>
</xs:complexType>
 
<xs:element type="ns:VehicleType" name="VehicleElement" nillable="true"/>
<xs:element type="ns:Car"  name="CarElement" nillable="true"/>
<xs:element type="ns:Motorcycle" name="MotorcycleElement" nillable="true"/> 
<xs:element type="ns:VehicleDescription" name="VehicleDescriptionElement"/>
 
 </xs:schema>
</wsdl:types>
 

<wsdl:message name="calculateValueBookValueMessage">
  <wsdl:part element="ns1:calculateBlueBookValue" name="BlueBookValuePart1" />
</wsdl:message>
 
<wsdl:message name="calculateBlueBookValueResponseMessage">
 <wsdl:part element="ns1:calculateBlueBookValueResponse" name="BlueBookValuePart1"/>
</wsdl:message>
 
<wsdl:portType name="BlueBookValuePart1">
 <wsdl:operation name="calculateBlueBookValue">
  <wsdl:input message="ns:calculateValueBookValueMessage"/>
  <wsdl:output message="ns:calculateBlueBookValueResponseMessage"/>
 </wsdl:operation>
</wsdl:portType>
 
<wsdl:binding type="ns:BlueBookValuePart1" name="BlueBookValueLocalhostBinding">
 <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
 <wsdl:operation name="calculateBlueBookValue">
  <soap:operation style="document" soapAction="urn:calculateBlueBookValue" />
  <wsdl:input><soap:body namespace="http://BlueBookValue.ve.recursionsw.com/types " use="literal" /></wsdl:input>
  <wsdl:output><soap:body namespace="http://BlueBookValue.ve.recursionsw.com/types" use="literal" /></wsdl:output>
 </wsdl:operation>
</wsdl:binding>
 
<wsdl:binding type="ns:BlueBookValuePart1" name="BlueBookValueHemmingsBinding">
 <Hemmings:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
 <wsdl:operation name="calculateBlueBookValue">
 <Hemmings:operation style="document" soapAction="urn:calculateBlueBookValue" />
  <wsdl:input><Hemmings:body namespace="http://BlueBookValue.ve.recursionsw.com/types " use="literal" /></wsdl:input>
  <wsdl:output><Hemmings:body namespace="http://BlueBookValue.ve.recursionsw.com/types" use="literal" /></wsdl:output>
 </wsdl:operation>
</wsdl:binding>
 
<wsdl:service name="BlueBookValue">
 
<wsdl:port binding="ns:BlueBookValueLocalhostBinding" name="BlueBookValueLocalhostPort">
 <!-- soap:address location="c:/Java/projects2/axis2-std-1.0testbed\build\wsdlBlueBookValue"/ -->
        <soap:address location="http://localhost:8080/axis/servlet/AxisServlet" />
</wsdl:port>
 
<wsdl:port binding="ns:BlueBookValueHemmingsBinding" name="BlueBookValueHemmingsPort">
 <!-- Hemmings:address location="c:/Java/projects2/axis2-std-1.0testbed\build\wsdlBlueBookValue"/ -->
        <soap:address location="http://wwwhemmings.com:8080/axis/servlet/AxisServlet" /> 
</wsdl:port>
 
</wsdl:service>
</wsdl:definitions>
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.
----- Original Message -----
From: Joshua Fox
Sent: Sunday, June 25, 2006 10:06 AM
Subject: Re: passing objects of subtypes

I'm looking for the ability to pass an object of runtime type Car when the declared parameter or return type is the superclass Vehicle. For this to happen, the serializer must pass runtime type information in our document-literal SOAP (an xsi:type attribute in the root element) saying that the serialized object is a Car.

In .NET, you do this with
http://www.topxml.com/xmlserializer/xmlincludeattribute.asp

This article mentions how to do it with WebSphere tools http://www-128.ibm.com/developerworks/websphere/techjournal/0401_brown/brown.html
but this seems non-standard.

There must be some standard way of doing it in Axis.

Thanks,


Joshua


Reply via email to