FWIW the basic method I've settled on is: install a "deserializer" that just accesses 
what you need from the message context. 

E.g. here's how to return an Element node containing the returned DOM (constants, 
imports etc. omitted):

//      in the client code:
//      after creating a Service object
TypeMapping tm = service.getTypeMappingRegistry().getDefaultTypeMapping();
tm.register(Element.class, WEATHER_TYPE, null, new WeatherDeserializerFactory());

//      WeatherDeserializer
public class WeatherDeserializer extends DeserializerImpl {
    public final void onEndElement(String namespace, String localName, 
DeserializationContext context)
            throws SAXException {
        try {
            MessageElement msgElem = context.getCurElement();
            if (msgElem != null) {
                        //      NOTE other options here, e.g. getRealElement()
                        //      which avoids redundant DOM-building
                value = msgElem.getAsDOM();
            }
        } catch (Exception exp) {
            throw new SAXException(exp);
        }
    }
}

//      WeatherDeserializerFactory
public class WeatherDeserializerFactory extends BaseDeserializerFactory {
    public WeatherDeserializerFactory() {
        super(WeatherDeserializer.class);
    }
}

...but this feels like a hack to me. Lots of moving parts to set up basically a 
trivial case. I'd still like to know the "real" way to do it.

Basil

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 24, 2002 5:20 PM
To: [EMAIL PROTECTED]
Subject: RE: newbie question (access to response message as DOM)


I too, would love to know how to get this to work.� Anyone?

   -----Original Message-----
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
   Sent: Tuesday, 24 September 2002 9:19
   To: [EMAIL PROTECTED]
   Subject: RE: newbie question (access to response message as DOM)
   
   

   
   Sorry, here's the WSDL:
   �
   <?xml version="1.0" encoding="utf-8"?>
   <definitions name="getCAWeather"
   �targetNamespace=" http://ocean.cse.ucsc.edu/soap/getCAWeather.wsdl";
   �xmlns:tns=" http://ocean.cse.ucsc.edu/soap/getCAWeather.wsdl";
   �xmlns:xsd1=" http://ocean.cse.ucsc.edu/soap/getCAWeather.wsdl";
   ������ xmlns:xsd=" http://www.w3.org/2000/10/XMLSchema";
   �xmlns:soap=" http://schemas.xmlsoap.org/wsdl/soap/";
   ������ xmlns=" http://schemas.xmlsoap.org/wsdl/";>
   �
   � <types>
   �<schema targetNamespace="
   http://ocean.cse.ucsc.edu/soap/getCAWeather.wsdl";
   ����������� xmlns=" http://www.w3.org/2000/10/XMLSchema";>
   ������� <complexType name="weather">
   ��������� <all>
   ����������� <element name="city" type="xsd:string"/>
   ����������� <element name="sky" type="xsd:string"/>
   ����������� <element name="tmp" type="xsd:int"/>
   ����������� <element name="dp" type="xsd:int"/>
   ����������� <element name="rh" type="xsd:int"/>
   ����������� <element name="wind" type="xsd:string"/>
   ����������� <element name="pres" type="xsd:string"/>
   ��������� </all>
   ������� </complexType>
   ��� </schema>
   � </types>
   �
   � <message name="getCAWeather">
   ��� <part name="find" type="xsd:string"/>
   � </message>
   �
   � <message name="getCAWeatherResponse">
   ��� <part name="ret" type="xsd1:weather"/>
   � </message>
   �
   � <portType name="getCAWeatherPortType">
   ��� <operation name="getCAWeather">
   ����� <input message="tns:getCAWeather"/>
   ����� <output message="tns:getCAWeatherResponse"/>
   ��� </operation>
   � </portType>
   �
   � <binding name="getCAWeatherBinding"
   type="tns:getCAWeatherPortType">
   ��� <soap:binding style="rpc" transport="
   http://schemas.xmlsoap.org/soap/http"/>
   ��� <operation name="getCAWeather">
   �<soap:operation soapAction="
   http://ocean.cse.ucsc.edu/soap/getCAWeather"/>
   ����� <input>
   �<soap:body use="encoded" namespace="
   http://ocean.cse.ucsc.edu/soap/getCAWeather";
   ����������� encodingStyle="
   http://schemas.xmlsoap.org/soap/encoding/"/>
   ����� </input>
   ����� <output>
   �<soap:body use="encoded" namespace="
   http://ocean.cse.ucsc.edu/soap/getCAWeather";
   ����������� encodingStyle="
   http://schemas.xmlsoap.org/soap/encoding/"/>
   ����� </output>
   ��� </operation>
   � </binding>
   �
   � <service name="getCAWeatherService">
   ��� <documentation> Generated by mod_soap </documentation>
   ��� <port name="getCAWeatherPort" binding="tns:getCAWeatherBinding">
   �<soap:address location="
   http://ocean.cse.ucsc.edu/soap/getCAWeather"/>
   ��� </port>
   � </service>
   �
   </definitions>
   

      -----Original Message-----
      From: Basil Hosmer [mailto:[EMAIL PROTECTED]] 
      Sent: Monday, September 23, 2002 4:17 PM
      To: '[EMAIL PROTECTED]'
      Subject: newbie question (access to response message as DOM)
      
      
      Hi,
      �
      Somebody please give me a shove in the right direction: I'm using
      Axis to make a call to a web service that returns a fairly simple
      <complexType> (wsdl attached). I've successfully deserialized
      using a generated bean, but what I'd really like is to simply
      access a DOM representation of the response. 
      �
      Naively I tried call.setOperationStyle("document") (also
      "message") - no luck - I get an Axis fault that appears to be
      generated while trying to create another axis fault (yipes).�
      �
      Tried also registering a type mapping that used
      ElementDeserializer, thinking it would give me the entire subtree
      underneath the top "element". Nope - at least, not without some
      setup I wasn't doing... I imagine that I could leave operation
      style set to "rpc" (as specified by the binding in the WSDL) and
      hand-write a subclass of ElementDeserializer - or DeserializerImpl
      - that would give back a DOM, but I'm really hoping that isn't
      necessary.) 
      �
      What basic thing am I missing? Or is this not a normal thing to be
      doing with Axis? 
      �
      Any guidance appreciated.
      �
      Basil

   


Reply via email to