axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lee Coomber <>
Subject WSDL2Java and xsd:any
Date Thu, 21 Oct 2004 20:34:48 GMT

I'm implementing a specification for a client and need to achieve a 
message on the wire along the lines of:-

<S11:Envelope xmlns:S11="…" xmlns:wst="…" xmlns:myNS="…"


The operation takes a WS-Trust RequestSecurityToken, an embedded 
WS-Trust Supporting element and a custom token after that. This is a 
valid combination because the types underlying the 
wst:RequestSecurityToken and wst:Supporting elements include the xsd:any 
type. I have XML schema and WSDL definitions and WSDL2Java is generating 
the various objects and services successfully. In my service I get 
passed a RequestSecurityTokenType object which has properties for 
TokenType and RequestType.

My problem in that although the any property contains a MessageElement 
with the wst:Supporting element in, there is no easy way to obtain a 
SupportingTokensType (underlying type of the wst:Supporting element) 
based on this. I have created a deserializer helper method which returns 
a filled object given a MessageElement and a class but to process all 
the types in the specification this way seems a very long way round and 
misses the power of Axis.

I started looking at creating extensions in the schema to define types 
that reflect what I receive on the wire, e.g.:-

<xsd:element name="MySupportingImpl" type="MySupportingImplType"/>

<xsd:complexType name="MySupportingImplType">
<xsd:extension base="wst:SupportingTokensType">
<xsd:element ref="MyCustomToken"/>
<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>

<xsd:element name="="MyCustomRequestType">" type="MyCustomRequestType"/>

<xsd:complexType name="MyCustomRequestType">
<xsd:extension base="wst:RequestSecurityTokenType">
<xsd:element ref="MySupportingImpl"/>
<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>

and in defining the input message in the WSDL document:-

<wsdl:message name="MyCustomMsg">
<wsdl:part name="MyCustomRequest" element="myNS:MyCustomRequestType">

Useful objects are created with correctly typed properties but 
serialization obviously produces names of the child elements rather than 
the parents. I may be able to get around this by generating helper 
classes that override the default generated type descriptions but again, 
this doesn't seem an ideal solution

Can anyone give me some pointers on a good way of achieving the messages 
I need using XML schema and WSDL? Any help gratefully received.

Many thanks for reading,


View raw message