XML & Web services: Polymorphism in Web Services

  1. Polymorphism in Web Services (1 messages)

    I am trying to understand how we can use polymorphic objects in web services. Is there any standard way to define sub-types in the WSDL? If you manually add complex types to the types element in the WSDL, will the clients be able to use these explicitly non-referenced sub-types?

    I have tried to use Axis wsdltojava, it did not generate client code for such non-referenced sub-types. Is this just a local problem with the Axis tool or is it problem accross Java based and non-Java based SOAP implementations?

    What are the guidelines for using Polymorphism in Web Services? How do you use lists like ArrayLists and Maps without such basic support for Poloymorphism?

    Any information in this area will be highly appreciated.


  2. Hi Kiran,
    Systinet WASP for Java has good support for polymorphism in Web Services.

    Often, a method parameter is just an interface allowing for more loosely coupled implementations. The WSDL for such a service may not contain all the required information. Example can be a method with an array of Objects as a parameter. Putting the instance of class to this array may mean that the opposite side won't understand the message. Extra types mapping allows the user to map additional Java types into the WSDL and send them via SOAP using type polymorphism. Using extra types can save a lot of hard work customizing WSDL.

     Adding extra type

    Java2WSDL examples.package.Service --add-type examples.StructureA --add-type examples.StructureB

    The result is that two types, examples.StructureA and examples.StructureB, are mapped to its XML Schema representation and added to the target WSDL. If structure is sent, necessary information can now be extracted from WSDL.

    If you download Wasp Installation package there are also polimorphism sample codes.

    WASP Server is free for development and 1 CPU deployment.

    Jaroslav Brazda
    Senior Engineer, Systinet

    Phone: +420 272 019 539
    eMail: jaroslav dot brazda at systinet dot com
    icq: 114543450