Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Web service Inheritance

Web service Inheritance

Web service Inheritance


I am having a problem with inheritance in my webservice.  I have a webservice that is working fine, but now I want to modify it to be more generic.  I want the parameter to the operation to be an abstract type that I can have other objects inherit from and be sent to the same webservice end point.  Then in the endpoint I can cast them into the appropriate type.

I have modified my WSDL so that the operation accepts an abstract type as a parameter and I have set up my two objects to inherit from this one abstract type.  When I build my webservice off the wsdl the jax-ws generated sources are generated fine.  My abstract object is built and the two objects that inherit from it are built.  The java code for my operation is fine too, it lets me cast from the abstract type into the other two types.

The issues comes when I send my requests into the operation, when the soap request comes in, the abstract object is always null.  Is what I am trying not possible?

Here is how I did it (this is just the pertinent stuff)


Schema definitions


<!-- abstract type -->
 <xsd:element name="AbstractType" abstract="true" type="ns:AbstractType" />
            <xsd:complexType name="AbstractType" />
<!-- first type to inherit -->
             <xsd:complexType name="Type1">
                    <xsd:extension base="ns:AbstractType">
                            <xsd:element name="EmployeeName" type="xsd:string"/>
                            <xsd:element name="Password" type="xsd:string"/>
                            <xsd:element name="EmployeeID" type="xsd:string"/>
                            <xsd:element name="OfficeId" type="xsd:string"/>
            <xsd:element xmlns:otns="http://www.otherexample.com" name="Type1" type="otns:Type1"/>
<!-- second type -->
            <xsd:complexType name="Type2">
                    <xsd:extension base="ns:AbstractType">
                            <xsd:element name="Username" type="xsd:string"/>
                            <xsd:element name="SecurityString" type="xsd:string"/>
                            <xsd:element name="IPAddress" type="xsd:string"/>
                            <xsd:element name="LoginUrl" type="xsd:string"/>
            <xsd:element xmlns:tns="http://www.example.com" name="Type2" type="tns:Type2"/>

Operation Definition:


<!-- operation accepts the Abstract type so I should be able to
send in either Type1 or Type2 -->
 <message name="logMeIn">
        <part name="mydata" element="vc:RequestData"/>
        <part name="headerStuff" element="ns:AbstractType" />

Then in my java code for the operation the headerStuff object comes in as null.  However, when I change the WSDL to accept either Type1 or Type2 and send the corresponding requests, the headerStuff comes in fine.

Any advice?  Is this even possible?


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close