Thanks for your help Steve and Doug.  This you guys have solved my problem I
think, I'm about to try it.  The real question I guess I was asking is in
regards to line Doug suggested.

       myparser.parse((String)ret.getValue());

This String that you cast from the Object returned from getValue(), is this
the entire XML response?  The apache docs don't really say what this object
would be.  When I used a SOAP method on the server that only returned one
piece of data, I just used "ret.getValue()" to get the value.  Now I'm
parsing the data returned from a much more complex method and I wanted to
use a DOM parser, or something accomplishing the same job of preserving the
data hierarchy.  I believe what you suggested will do this now.  Thank you
for the help from both of you.

One more question.  Is there a way to build a Java class from this XML data?
Then I could have a dynamically created class with accessors to get each
piece of data from the XML document originally returned.  Using reflection
classes I could then determine the data returned.  

I wish to do this because in the future, the data returned from some method
could change and I don't want to hard-code the names of the XML nodes and
attributes I'm reading from the SOAP response.  Eventually, maybe I could
even have the WebService return a Java class, in bytecode, with all the
methods on the webservice.  So that the client could dynamically discover
the methods available on the SOAP service.  Anyone have any thoughts on
doing this?

Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: [EMAIL PROTECTED]


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 31, 2001 1:51 PM
To: [EMAIL PROTECTED]
Cc: Soap-dev List (E-mail); Soap-user list (E-mail)
Subject: Re: Using Xerces to parse a SOAP response



Peter,
     You mentioned returning a String...is your string an xml doc?(if not
it could be...) you can do the following from receiving a Soap call if you
know that your method invoked returns a string such as "<a xmlns
="yournamespace"><b>12</b><c>56</c></a>"
try
{
     resp = call.invoke(url,"http://tempuri.org/action/youraction";);
}
catch (SOAPException e)
     {
       System.err.println("Caught SOAPException (" +
                               e.getFaultCode() + "): " +
                               e.getMessage());
       return;
     }
     // Check the response.
     if (!resp.generatedFault())
     {
       Parameter ret = resp.getReturnValue();
       DOMParser myparser = new DOMParser();
       myparser.parse((String)ret.getValue());
       Document doc = myparser.getDocument();
       //now you can do whatever you want with your dom
document....although you may want to try a SAX parser as it will be faster
and you can create your java objects without having the overhead of the
DOM.
     }
     else
     {
       Fault fault = resp.getFault();

       System.err.println("Generated fault: ");
       System.out.println ("  Fault Code   = " + fault.getFaultCode());
       System.out.println ("  Fault String = " + fault.getFaultString());
     }

etc...

hth
Doug

Reply via email to