axis-java-user mailing list archives

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

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="…"
<S11:Header>…</S11:Header>

<S11:Body>
<wst:RequestSecurityToken>
<wst:TokenType>…</wst:TokenType>
<wst:RequestType>
http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue
</wst:RequestType>
<wst:Supporting>
<myNS:MyCustomToken>
…
</myNS:MyCustomToken>
</wst:Supporting>
</wst:RequestSecurityToken>
</S11:Body>
</S11:Envelope>

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:complexContent>
<xsd:extension base="wst:SupportingTokensType">
<xsd:sequence>
<xsd:element ref="MyCustomToken"/>
<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>


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

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

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

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

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,

Lee

Mime
View raw message