Suteertha,

For an example of how to design extensible SOAP message elements, take a
look at the schema and WSDL for WS-Trust:
Schema:
http://www-106.ibm.com/developerworks/library/specification/ws-trust/ws-trus
t.xsd  
WSDL:
http://www-106.ibm.com/developerworks/library/specification/ws-trust/ws-trus
t.wsdl  

The pertinent bits are:

<xs:element name='RequestSecurityToken' 
    type='wst:RequestSecurityTokenType' />
<xs:complexType name='RequestSecurityTokenType' >
   <xs:sequence>
        <xs:any namespace='##any' processContents='lax' 
           minOccurs='0' maxOccurs='unbounded' />
   </xs:sequence>
   <xs:anyAttribute namespace='##other' processContents='lax' />
</xs:complexType>

<wsdl:message name="RequestSecurityTokenMsg">
    <wsdl:part name="request" element="wst:RequestSecurityToken" /> 
</wsdl:message>

So, if you want your SOAP message to look like this:

<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; >
   <SOAP-ENV:Body>
     <m:Document xmlns:m="http://www.openuri.org/";>
        <x:ABC xmlns:x="urn:abc">abc</ABC>
     </m:Document>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Then I suggest you define your schema like this:
<xs:element name='Document' type='tns:Document' />
<xs:complexType name='AnyDocumentType' >
   <xs:sequence>
        <xs:any namespace='##any' processContents='lax' 
           minOccurs='0' maxOccurs='unbounded' />
   </xs:sequence>
</xs:complexType>

And your WSDL message like this:
<wsdl:message name="processMessageRequest">
    <wsdl:part name="request" element="tns:Document" /> 
</wsdl:message>

Also -- your generated WSDL seems to have a couple of errors in it:

The schema element definition for Document:
<element name=">processMessage>document" type="xsd:anyType"/>

What's with the ">processMessage>" prefix to the name? Is this perhaps a
cut-and-paste error, or is this what your WSDL really looks like?

Also, input and output message definitions for doc/literal messages should
not specify namespace attributes unless you intend to override the schema's
namespace (which you shouldn't do):

<wsdl:input>
  <wsdlsoap:body use="literal" namespace="http://www.openuri.org/"/>
</wsdl:input>

Did you insert this namespace or specify a required namespace in your WSDD? 
If not, and Axis just generated it, then it's a bug -- so please file a bug
report.

Regards,
Anne

________________________________________
From: Guha, Suteertha [IE] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 02, 2004 5:27 PM
To: '[EMAIL PROTECTED]'
Subject: xsd:anyType in document style webservice

I need help and direction from the gurus.
�
I am trying to build a webservice that is generic enough to accept ANY XML
document, and return ANY XML document, so that it can be reused over and
over again for several intranet components. I know I am losing schema vals
etc coming with the SOAP layers by using anyType. See the attached WSDL. 
�
Although I can see the message come in over the wire faithfully, when I try
to print the SOAP Body (which will be the parameter in the Impl class
method), I get null. ( The line : System.out.println ("SOAP BODY : " +
processMessageDocument) ;). The hardcoded XML response comes out nice.
�
I am confused why this would happen. I should be able to extract data
directly from the parameters.
�
I also do not understand as to why in a document style web service, XML SPY
is spitting out the method name in the SOAP message. I tried removing
processMessage from the input, I get a 500 error. So it is required. But I
do not understand why.
�
Any help will be truly appreciated. Please bear with the fact that there is
no attachment, its all cut n paste.
�
My Impl code : 
=============
package org.openuri.www;
�
import java.io.* ;
import java.rmi.* ;
import java.util.* ;
�
import org.w3c.dom.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
�
import javax.xml.parsers.*;
�
import javax.xml.soap.* ;
�
import org.apache.axis.MessageContext ;
�
public class BlobSoapImpl implements org.openuri.www.BlobSoap
{
��� public java.lang.Object processMessage(java.lang.Object
processMessageDocument) throws java.rmi.RemoteException
��� {
������� try
������� {
������ �ByteArrayOutputStream ostr = new ByteArrayOutputStream() ;
�
������� MessageContext msgContext = MessageContext.getCurrentContext();
�
������� SOAPMessage soapMsg = msgContext.getMessage() ;
������� soapMsg.writeTo (ostr) ;
������� System.out.println ("SOAP MESSAGE ON THE WIRE : \n" +
ostr.toString()) ;
�
������� ��������System.out.println ("SOAP BODY : " + processMessageDocument)
;
�
������� DocumentBuilderFactory domFactory =
DocumentBuilderFactory.newInstance();
������� domFactory.setValidating(false);
�
������� DocumentBuilder domBuilder = domFactory.newDocumentBuilder () ;
�
������� Document document = domBuilder.parse (new File
("/u/sguha/blob/client/SOAPRSP")) ;
�
������� return document ;
������� }
������� catch (Exception e)
������� {
����������� e.printStackTrace() ;
������� }
�
������� return null ;
��� }
}
++++++++++++++++++++
Input data, from SPY 
++++++++++++++++++++�: 
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
������ <SOAP-ENV:Body>
������������ <m:processMessage xmlns:m="http://www.openuri.org/";>
������������������� <m:document><ABC>abc</ABC></m:document>
������������ </m:processMessage>
������ </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
�
+++++++++++++++++++++
WSDL : 
++++++++++++++++++++
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:impl="http://www.openuri.org/"; xmlns:intf="http://www.openuri.org/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://www.openuri.org/";>
������ <wsdl:types>
������������ <schema elementFormDefault="qualified"
targetNamespace="http://www.openuri.org/";
xmlns="http://www.w3.org/2001/XMLSchema";>
������������������� <element name="processMessage">
�������������������������� <complexType>
�������������������������������� <sequence>
��������������������������������������� <element
name=">processMessage>document" type="xsd:anyType"/>
�������������������������������� </sequence>
�������������������������� </complexType>
������������������� </element>
������������������� <element name="processMessageResponse">
�������������������������� <complexType>
�������������������������������� <sequence>
��������������������������������������� <element name="processMessageResult"
type="xsd:anyType"/>
�������������������������������� </sequence>
�������������������������� </complexType>
������������������� </element>
������������ </schema>
������ </wsdl:types>
������ <wsdl:message name="processMessageRequest">
������������ <wsdl:part name="parameters" element="impl:processMessage"/>
������ </wsdl:message>
������ <wsdl:message name="processMessageResponse">
������������ <wsdl:part name="parameters"
element="impl:processMessageResponse"/>
������ </wsdl:message>
������ <wsdl:portType name="BlobSoap">
������������ <wsdl:operation name="processMessage" parameterOrder="">
������������������� <wsdl:input name="processMessageRequest"
message="impl:processMessageRequest"/>
������������������� <wsdl:output name="processMessageResponse"
message="impl:processMessageResponse"/>
������������ </wsdl:operation>
������ </wsdl:portType>
������ <wsdl:binding name="BlobSoapSoapBinding" type="impl:BlobSoap">
������������ <wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
������������ <wsdl:operation name="processMessage">
������������������� <wsdlsoap:operation
soapAction="http://www.openuri.org/processMessage"/>
������������������� <wsdl:input>
�������������������������� <wsdlsoap:body use="literal"
namespace="http://www.openuri.org/"/>
������������������� </wsdl:input>
������������������� <wsdl:output>
�������������������������� <wsdlsoap:body use="literal"
namespace="http://www.openuri.org/"/>
������������������� </wsdl:output>
������������ </wsdl:operation>
������ </wsdl:binding>
������ <wsdl:service name="Blob">
������������ <wsdl:port name="BlobSoap" binding="impl:BlobSoapSoapBinding">
������������������� <wsdlsoap:address
location="http://taste.mk.telcordia.com:6254/axis/services/BlobSoap"/>
������������ </wsdl:port>
������ </wsdl:service>
������ <!-- 
WSDL created by Apache Axis version: 1.2beta
Built on Mar 31, 2004 (12:47:03 EST)
� -->
</wsdl:definitions>
�
�
�
�
�
�

Reply via email to