axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Silvester Pozarnik" <silvester.pozar...@tracetracker.com>
Subject Response Header deserialization?
Date Mon, 06 Jun 2005 13:43:47 GMT
Is there any magic in handling the response headers when using the
WSDL2Java tool (axis 1.2)? 

 

Given the WSDL definition (fragment):

...

 <s:element name="gepirRequestHeader">

  <s:complexType>

   <s:sequence>

    <s:element minOccurs="1" maxOccurs="1" name="requesterGln"
type="s:string"/>

    <s:element minOccurs="0" maxOccurs="1" name="cascade" type="s:int"/>

   </s:sequence>

  </s:complexType>

 </s:element>

 <s:element name="gepirResponseHeader">

  <s:complexType>

   <s:sequence>

    <s:element minOccurs="1" maxOccurs="1" name="responderGln"
type="s:string"/>

    <s:element minOccurs="1" maxOccurs="1" name="numberOfHits"
type="s:int"/>

    <s:element minOccurs="1" maxOccurs="1" name="returnCode"
type="s:int"/>

   </s:sequence>

  </s:complexType>

 </s:element>

...

<wsdl:message name="GetOwnerOfGLNSoapIn">  <wsdl:part
name="GetOwnerOfGLNRequest" element="ns:GetOwnerOfGLN"/> </wsdl:message>
<wsdl:message name="GetOwnerOfGLNSoapOut">  <wsdl:part
name="GetOwnerOfGLNResult" element="ns:gepirParty"/> </wsdl:message> ...

<wsdl:portType name="routerSoap">

 <wsdl:operation name="GetOwnerOfGLN">

  <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get owner of a
GLN</documentation>

  <wsdl:input message="ns:GetOwnerOfGLNSoapIn"/>

  <wsdl:output message="ns:GetOwnerOfGLNSoapOut"/>

 </wsdl:operation>

...

<wsdl:binding name="routerSoap" type="ns:routerSoap">  <soap:binding
style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

 <wsdl:operation name="GetOwnerOfGLN">

  <soap:operation soapAction="http://www.gepir.org/GetOwnerOfGLN"
style="document"/>

  <wsdl:input>

   <soap:body use="literal"/>

   <soap:header message="ns:msgRequestHeader" part="gepirRequestHeader"
use="literal" namespace="http://www.gepir.org/"/>

  </wsdl:input>

  <wsdl:output>

   <soap:body use="literal"/>

   <soap:header message="ns:msgResponseHeader"
part="gepirResponseHeader" use="literal"
namespace="http://www.gepir.org/"/>

  </wsdl:output>

 </wsdl:operation>

...

 

The WSDL2Java tool generates the client side RouterSoap_BindingStub as
it should and there are also gepirRequestHeader and gepirResponseHeader
classes available. Great! But my problem is that I can not find a way to
automagically deserialize the response header (gepirResponseHeader):

 

      RouterLocator rl = new RouterLocator();

      rl.setEndpointAddress( "routerSoap",
setup.getSoapEndPointAddress() ); // RouterSoap_BindingStub is generated
by WSDL2Java

      RouterSoap_BindingStub binding = (RouterSoap_BindingStub)
rl.getrouterSoap();           

// initialize the header

      GepirRequestHeader hdrs = new GepirRequestHeader();

      hdrs.setCascade( new Integer( 8 ) );

      hdrs.setRequesterGln( setup.getLocalGLN() );

      binding.setHeader( ns, "gepirRequestHeader", hdrs ); // pass the
header

 

// create and populate the input parameter

      GetOwnerOfGLN go = new GetOwnerOfGLN();

      go.setVersion( new BigDecimal( setup.getVersion() ) );

      go.setRequestedGln( msgin.getVal() );

      try {

       GepirParty value = binding.getOwnerOfGLN( go ); // invoke

 

      // is this only way to access the headers?

       SOAPHeaderElement[] hel = binding.getResponseHeaders();

       SOAPHeaderElement she = binding.getResponseHeader(ns,
"gepirResponseHeader");

 

// ????

            gepirResponseHeader grh = ???

 

 

What I've got is the SOAPHeaderElement (a DOM Node object) containing
the <gepirResponseHeader xmlns="http://www.gepir.org/"> element, but
what I want is a deserialized java class gepirResponseHeader that
WSDL2Java has generated for me. The odd thing is that the input and
output parameters as well as request headers are automatically
serialized/deserialized by generated client stub, but with response
header you have to write code that deal with XML and DOM. Am I missing
something?  

 

 

BTW., the content of the response message is as follows:

 

 

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/

               xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

               xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <soap:Header>

  <gepirResponseHeader xmlns="http://www.gepir.org/">

   <responderGln xmlns="">7600001000141</responderGln>

   <numberOfHits xmlns="">1</numberOfHits>

   <returnCode xmlns="">0</returnCode>

  </gepirResponseHeader>

 </soap:Header>

 <soap:Body>

  <gepirParty xmlns="http://www.gepir.org/">

   <partyDataLine xmlns="">

    <gln>7080000718177</gln>

    <partyName>MEANTIME RECORDS </partyName>

    <streetAddress>NOBELSG 35</streetAddress>

    <postalCode>0268</postalCode>

    <city>OSLO</city>

    <countryISOCode>NO</countryISOCode>

    <contact>

     <contactName>Karin Krog</contactName>

     <communicationChannel
communicationChannelCode="TELEPHONE">+4722446509</communicationChannel>

     <communicationChannel
communicationChannelCode="TELEFAX">+4722436015</communicationChannel>

    </contact>

   </partyDataLine>

  </gepirParty>

 </soap:Body>

</soap:Envelope>

 

BR

Silvester Pozarnik

 

 

 

 


Mime
View raw message