axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh_santosh <santosh.nc...@gmail.com>
Subject How to add explicit SOAP header in WSDL for generating SOAP message - Axis1.4
Date Mon, 05 Oct 2009 09:31:30 GMT

Dear All,

I need to expose java web services. I am using Axis1.4, Java 1.5 and Tomcat
5.0 for exposing services.

SOAP request and SOAP response have 'authentication' tag in SOAP header. 

SOAP Request -

<S:Envelope>
        <S:Header>
             <authentication>
                   <userid>UserName</userid>
                   <password>Password</password>
            </authentication>
        </S:Header>
        <S:Body>
              <OTA_TestAvailRQ EchoToken="LI" Target="Production"
Version="1.0">
              .......................................
              </OTA_TestAvailRQ>
        </S:Body>
</S:Envelope>
--------------------------------------------------------------
SOAP response  -

<S:Envelope>
        <S:Header>
             <wsp:authentication>
                     <wsp:userid>XXUserName</wsp:userid>
                     <wsp:password>XXPassword</wsp:password>
                     <wsp:payloadVersion>2007B</wsp:payloadVersion>
            </wsp:authentication>
        </S:Header>
        <S:Body>
               <OTA_TestAvailRS EchoToken="LI" PrimaryLangID="en"
Target="Production"                                               
TimeStamp="2009-03-24T20:26:37.058+01:00" Version="1.006">
              ................
              </OTA_TestAvailRS>
        </S:Body>
</S:Envelope>

By seeing the SOAP message structure, we have decided to add SOAP header
explicitly in WSDL.
We are NOT able  to differentiate between SOAP request and SOAP response
'authentication' tag in WSDL.

We have attempted to solve the above problem by creating 2 different type of
WSDL.
Please have look into these wsdl.

WSDL-1 :

<wsdl:definitions targetNamespace="http://test.com"
xmlns:tns="http://test.com" 
	xmlns="http://schemas.xmlsoap.org/wsdl/"	
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<wsdl:types>
		<xsd:schema targetNamespace="http://test.com">
		<!-- SOAP Request Header -->
			<xsd:element name="Authentication">
                        <xsd:complexType>
                                <xsd:sequence>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="userid" type="xsd:string"/>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="password" type="xsd:string"/>                                     
  
                                </xsd:sequence>
                        </xsd:complexType>
            </xsd:element>
            <!-- SOAP Response Header -->
            <xsd:element name="Authentication">
                        <xsd:complexType>
                                <xsd:sequence>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="userid" type="xsd:string"/>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="password" type="xsd:string"/>
                                        <xs:element minOccurs="1"
maxOccurs="1" name="payloadVersion" type="xs:string"/>                                
       
                                </xsd:sequence>
                        </xsd:complexType>
            </xsd:element>
		</xsd:schema>
   </wsdl:types>
   
   
   <wsdl:message name="HelloMessage">
   	  <wsdl:part name="headerRQ" element="tns:Authentication"/>   	  
      <wsdl:part name="body" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="HelloMessageResponse">   
      <wsdl:part name="headerRS" element="tns:Authentication"/>	  
      <wsdl:part name="body" type="xsd:string"/>
   </wsdl:message>
   <wsdl:portType name="HelloPortType">
      <wsdl:operation name="sayHello">
         <wsdl:input message="tns:HelloMessage"/>
         <wsdl:output message="tns:HelloMessageResponse"/>
         </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="HelloBinding" type="tns:HelloPortType">
         <wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
         <wsdl:operation name="sayHello">
         <wsdlsoap:operation soapAction="" />
            <wsdl:input>
               <wsdlsoap:body use="literal"/>               
               <wsdlsoap:header part="header" use="literal"/>
         </wsdl:input>
         <wsdl:output>
            <wsdlsoap:body use="literal"/> 
            <wsdlsoap:header part="header" use="literal"/>           
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="HelloService">
      <wsdl:port binding="tns:HelloBinding" name="HelloPort">
         <wsdlsoap:address
location="http://localhost:8080/hello-service/hello-service"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

WSDL-2 :

<wsdl:definitions targetNamespace="http://test.com"
xmlns:tns="http://test.com" 
	xmlns="http://schemas.xmlsoap.org/wsdl/"	
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<wsdl:types>
		<xsd:schema targetNamespace="http://test.com">
		<!-- SOAP Request Header -->
			<xsd:element name="Authentication">
                        <xsd:complexType>
                                <xsd:sequence>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="userid" type="xsd:string"/>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="password" type="xsd:string"/>                                     
  
                                </xsd:sequence>
                        </xsd:complexType>
            </xsd:element>
            <!-- SOAP Response Header -->
            <xsd:element name="Authentication">
                        <xsd:complexType>
                                <xsd:sequence>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="userid" type="xsd:string"/>
                                        <xsd:element minOccurs="1"
maxOccurs="1" name="password" type="xsd:string"/>
                                        <xs:element minOccurs="1"
maxOccurs="1" name="payloadVersion" type="xs:string"/>                                
       
                                </xsd:sequence>
                        </xsd:complexType>
            </xsd:element>
		</xsd:schema>
   </wsdl:types>
   
   <wsdl:message name="headerRQ">
   	  <wsdl:part name="header" element="tns:Authentication"/> 	        
   </wsdl:message>
   
   <wsdl:message name="headerRS">
   	  <wsdl:part name="header" element="tns:Authentication"/>       
   </wsdl:message>  
   
   <wsdl:message name="HelloMessage">   	  	  
      <wsdl:part name="body" type="xsd:string"/>
   </wsdl:message>
   
   <wsdl:message name="HelloMessageResponse">         
      <wsdl:part name="body" type="xsd:string"/>
   </wsdl:message>
   
   <wsdl:portType name="HelloPortType">
      <wsdl:operation name="sayHello">
         <wsdl:input message="tns:HelloMessage"/>
         <wsdl:output message="tns:HelloMessageResponse"/>
         </wsdl:operation>
      </wsdl:portType>
      
      <wsdl:binding name="HelloBinding" type="tns:HelloPortType">
         <wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
         <wsdl:operation name="sayHello">
         <wsdlsoap:operation soapAction="" />
            <wsdl:input>
               <wsdlsoap:body use="literal"/>               
               <wsdlsoap:header message="tns:headerRQ" part="header"
use="literal"/>
         </wsdl:input>
         <wsdl:output>
            <wsdlsoap:body use="literal"/> 
            <wsdlsoap:header message="tns:headerRS" part="header"
use="literal"/>           
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   
   <wsdl:service name="HelloService">
      <wsdl:port binding="tns:HelloBinding" name="HelloPort">
         <wsdlsoap:address
location="http://localhost:8080/hello-service/hello-service"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>


Please advise.

Regards,
Santosh
-- 
View this message in context: http://www.nabble.com/How-to-add-explicit-SOAP-header-in-WSDL-for-generating-SOAP-message---Axis1.4-tp25747709p25747709.html
Sent from the Axis - User mailing list archive at Nabble.com.


Mime
View raw message