We have been trying to upgrade from Axis 1.5.4 to Axis2 1.6.0 and are
stumped by Axis2 not correctly serializing a custom soap header
defined in the server’s wsdl.

The definition of the custom header defined in the wsdl is

           <xs:element name="RequestHeader">
               <xs:complexType>
                   <xs:all>
                       <xs:element name="ipaddress" type="xs:string">
                           <xs:annotation>
                               <xs:documentation>
                                   This should contain the IP address
on which the client is running.
                               </xs:documentation>
                           </xs:annotation>
                       </xs:element>
                       <xs:element name="serverId" type="xs:string">
                           <xs:annotation>
                               <xs:documentation>
                                     the edge server handling the
external client connection
                               </xs:documentation>
                           </xs:annotation>
                       </xs:element>
                       <xs:element name="sessionId" type="xs:string">
                           <xs:annotation>
                               <xs:documentation>
                                   external client's session id on
the edge server
                               </xs:documentation>
                           </xs:annotation>
                       </xs:element>
                   </xs:all>
               </xs:complexType>
           </xs:element>

   <wsdl:message name="RequestHeader">
       <wsdl:part element="sch:RequestHeader" name="RequestHeader">
       </wsdl:part>
   </wsdl:message>

And the header is included in each soap operation

       <wsdl:operation name="Authentication">
           <soap:operation soapAction=""/>
           <wsdl:input name="AuthenticationRequest">
               <soap:body use="literal"/>
               <soap:header message="tns:RequestHeader"
part="RequestHeader" use="literal">
               </soap:header>
           </wsdl:input>
           <wsdl:output name="AuthenticationResponse">
               <soap:body use="literal"/>
           </wsdl:output>
       </wsdl:operation>

When the axis2 client tries to serialize the RequestHeader object only
the first child element (‘ipaddress’) is correctly serialized, the
other two child elements (‘serverId’ and ‘sessionId’) are ignored.

The resulting soap message

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
 <soapenv:Header>
 <sch:RequestHeader xmlns:sch="http://cithaeron.com/schemas";
soapenv:mustUnderstand="0">
  <sch:ipaddress>127.0.0.2</sch:ipaddress>
 </sch:RequestHeader>
 </soapenv:Header>
 <soapenv:Body>
 <sch:AuthenticationRequest xmlns:sch="http://cithaeron.com/schemas";>
  <sch:loginName>remvoed</sch:loginName>
  <sch:password>removed</sch:password>
 </sch:AuthenticationRequest>
 </soapenv:Body>
</soapenv:Envelope>

 The code below was run with XmlBeans but the same behavior was seen with ADB

       final PublicServiceStub publicStub = new
PublicServiceStub(zeusPublicUrl);

       final RequestHeaderDocument requestHeaderDoc =
RequestHeaderDocument.Factory.newInstance();
       final RequestHeaderDocument.RequestHeader requestHeader =
requestHeaderDoc.addNewRequestHeader();
       requestHeader.setIpaddress("127.0.0.1");
       requestHeader.setServerId("192.168.1.1");
       requestHeader.setSessionId("mySessionId");


       final AuthenticationRequestDocument requestDoc =
AuthenticationRequestDocument.Factory.newInstance();
       final AuthenticationRequestDocument.AuthenticationRequest
request = requestDoc.addNewAuthenticationRequest();
       request.setLoginName("removed");
       request.setPassword("removed");
       final AuthenticationResponseDocument responseDoc =
publicStub.authentication(requestDoc, requestHeaderDoc);
       final AuthenticationResponseDocument.AuthenticationResponse
response = responseDoc.getAuthenticationResponse();
       log.info("serverId:  " + response.getServerId());
       log.info("sessionId:  " + response.getSessionId());
       log.info("ipaddress:  " + response.getIpaddress());


-Fazle

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org
For additional commands, e-mail: java-user-h...@axis.apache.org

Reply via email to