I think the problem is that WSDL2Java can't anticipate how you're planning 
to use the XML that's returned.  Anyway, it's easy enough to get the entire 
body of a SOAP message returned by some service.  Attached is an example 
client that does this.  Instantiate the service with a String that holds 
the XML of the message you want to send to the service; then run 
makeCall().  It returns a String representation of the SOAP body returned.

Andrew

At 04:17 PM 4/30/2002 +0200, you wrote:

>So what you are suggesting is to forget about all the beans and just 
>extract the XML from the SOAP envelope?
>
>But wouldn't it be better if WSDL2Java would generate this code? It seems 
>simple enough.
>Or is the .NET way not standard enough to it that way?
>
>-Tako
>
>
> > -----Original Message-----
> > From: St-Germain, Sylvain [mailto:[EMAIL PROTECTED]]
> > Sent: dinsdag 30 april 2002 16:06
> > To: [EMAIL PROTECTED]
> > Subject: RE: How to retrieve an XML document from a service?
> >
> >
> >
> > After you made your call you can get to the SOAP envelope using:
> >
> > service.getCall().getResponseMessage().getSOAPPart()
> >
> > Sylvain.
> >
> > -----Original Message-----
> > From: Tako Schotanus [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, April 30, 2002 5:20 AM
> > To: [EMAIL PROTECTED]
> > Subject: How to retrieve an XML document from a service?
> >
> >
> > I used WSDL2Java to generate some code for a .NET web service
> > that returns
> > an XML document as a result.
> > After inspecting the code I noticed that all XML document
> > results had been
> > converted to Beans.
> >
> > Can somebody point me in the direction I should go to get
> > from a Bean to the
> > original XML document?
> > Is this bean stuff even necessary or is it just the code
> > generator that
> > doesn't know how to handle .NET XML document types and turns
> > everything
> > unknown into beans?
> >
> > I did find the info about the ElementDeserializer, but
> > couldn't figure out
> > how to use them.
> >
> > Any help would be much appreciated :-)
> >
> > -Tako
> >
> >
> > Tako Schotanus
> > Chief Software Architect
> >
> > --------------------------------------------------------
> > BackStream® Content Management
> >
> > Postbus 58385
> > 1040 HJ Amsterdam
> >
> > Willem de Zwijgerlaan 350
> > 1055 RD Amsterdam
> >
> > The Netherlands
> >
> > tel. +31 (0)20 6827332 / fax +31 (0)20 6827632
> >
> > http://www.backstream.com
> > --------------------------------------------------------
> >
> > This message may contain privileged and/or confidential
> > information.  If you
> > have received this e-mail in error or are not the intended
> > recipient, you
> > may not use, copy, disseminate or distribute it; do not open any
> > attachments, delete it immediately from your system and
> > notify the sender
> > promptly by e-mail that you have done so.  Thank you.
> >
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.utils.Options;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import java.net.URL;
import java.util.Vector ;
import java.io.*;

public class DocumentClient {
    private String bodyxml;
    
    public String makeCall() throws Exception {
        Options opts = new Options(new String[] {});
        opts.setDefaultURL("http://localhost:8000/axis/services/myService";);

        Service  service = new Service();
        Call     call    = (Call) service.createCall();

        call.setTargetEndpointAddress( new URL(opts.getURL()) );
        SOAPBodyElement[] input = new SOAPBodyElement[1];
        
        InputStream inp = new ByteArrayInputStream(bodyxml.getBytes("ISO-8859-1"));
        Document bodyDOM = XMLUtils.newDocument(inp);
        Element bodyElement = bodyDOM.getDocumentElement();
        SOAPBodyElement sbe = new SOAPBodyElement(bodyElement);
        sbe.setNamespaceURI("foo");
        input[0] = sbe;
        
        Vector          elems = (Vector) call.invoke( input );
        SOAPBodyElement elem  = null ;
        Element         e     = null ;
        if(elems != null && elems.size() > 0){
          elem = (SOAPBodyElement) elems.get(0);
          e    = elem.getAsDOM();
        }
        String str = XMLUtils.ElementToString(e);
        return( str );
    }

    public DocumentClient(String text) throws Exception {
      bodyxml = text;
    }
    
}



Reply via email to