You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Samprathi, Subramani non Unisys" <Su...@unisys.com> on 2003/06/24 01:55:00 UTC

SOAP Header for .NET client

Hello everybody,
I am using weblogic and axis with .NET as the webservice consumer.
I need to use both request and response headers.
The generated WSDL with axis does not have any request/response header
information. 
Is there way to generate this ?  is there any command line options in
JAVA2WSDL utility that I am missing?
Also I tried manually adding request/reponse header information in the WSDL,
but the "WSDL.exe" utility is giving errors when generating the proxy.
Can somebody help me with the header ?
Cheers,
Subbu

Re: SOAP Header for .NET client

Posted by Florian Lindauer <fl...@secure-net.de>.
Samprathi, Subramani non Unisys wrote:
> I need to use both request and response headers.
> The generated WSDL with axis does not have any request/response header 
> information.
> Is there way to generate this ?  is there any command line options in 
> JAVA2WSDL utility that I am missing?

I don't know for sure (just an Axis-user myself), but I think there
are currently no mechanisms for automated Header-handling in Axis.
You would need a syntax to inform Axis of headers for methods,
like in .NET with that brackets, or perhaps in the deployment
descriptor. Only then Axis could know of which headers are required
in which operations and generate appropriate WSDL.

What I did is to manipulate the WSDL myself, using the same
handler that sets/reads the headers, implementing / overwriting
the generateWSDL-method therein.
There you can get and acces the WSDL:

   Document doc = (Document) msgContext.getProperty("WSDL");
   if (doc != null) // WSDL is there only in response-chain
   { ... full DOM access to WSDL-XML-document ...
   }

Of course you need to put in correct WSDL, then .NETs
proxy generator will not give errors. There are three
things you need to add:

1. Add the header data-type in the schema-definitions
    (wsdl:types) like this:

    <schema targetNamespace="..myTargetNamespace..">
     <complexType name="MyHeaderType">
      <sequence>
       <element maxOccurs="1" minOccurs="1" name="id" type="xsd:long"/>
      </sequence>
     </complexType>
    </schema>

    This is a complex type even for only one field, because only
    then .NET can automatically handle the headers.

2. Add a message definition like this:

    <wsdl:message name="MyHeader">
     <part name="myHeader" type="ns1:MyHeaderId"
           xmlns:ns1="..myTargetNamespace.."/>
    </wsdl:message>

3. In Bindings, for each operation where you need a header,
    include it like this:

    <wsdl:operation name="myOperation1">
     <wsdlsoap:operation soapAction=""/>
     <wsdl:input name="myOperation1Request">
      <wsdlsoap:body .../>
      <wsdlsoap:header
         encodingStyle="..." namespace="..."
         message="impl:MyHeader"
         part="myHeader" use="encoded"/>
     </wsdl:input>
     <wsdl:output name="myOperation1Response">
      <wsdlsoap:body .../>
     </wsdl:output>
    </wsdl:operation>


Hope that helps.

Of course, it would be a nice feature for the future of Axis
to support headers in WSDL.


-- 
Florian Lindauer


Re: SOAP Header for .NET client

Posted by Florian Lindauer <fl...@secure-net.de>.
small error in my previous mail:

2. Add a message definition like this:

    <wsdl:message name="MyHeader">
     <part name="myHeader" type="ns1:MyHeaderId"
           xmlns:ns1="..myTargetNamespace.."/>
    </wsdl:message>

REPLACE second line with:

     <part name="myHeader" type="ns1:MyHeaderType"