So this one solution is not more then building the xml doc posting it
(HttpURLConnection) 

Reading the response (soap envelope) & parse that (with dom or jdom
etc..) 
 InputStreamReader isr = new
InputStreamReader(httpConn.getInputStream());

So no apache soap and stuff needed here ?
This was my first approach I tried and this works ..

See example 
http://www-106.ibm.com/developerworks/xml/library/x-soapcl/listing1.html

But I wasn't quite happy with this approach ..
I thought Apache SOAP was more clean but so far parsing the response
from the .NET service doesn't work ..

Regards,
Tom


-----Original Message-----
From: Erich Izdepski [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 18, 2002 2:15 PM
To: [EMAIL PROTECTED]
Subject: RE: how to work with the response object ?

Tom-
there is RPC style SOAP and document style SOAP. RPC returns an object-
that's just the way it works. Document style deals with passing XML
documents around as SOAP input and output (not in apache, but in .net).
There is an in-between approach that may be what you want.
http://xml.apache.org/soap/features.html decribes an apache feature:
"Literal XML encoding: allows one to send XML elements (DOM
org.w3c.dom.Element objects) as parameters by embedding the literal XML
serialization of the DOM tree. No code needs to be written to support
this (see the addressbook demo to see a sample use of it)." Apache also
supports message clients/services that can work with XML directly. See
the user's guide for more.

Here's an article that talks about the two styles:
http://www.infoworld.com/articles/fe/xml/02/03/25/020325fejavatca.xml

Erich Izdepski
Senior Software Engineer
Cysive, Inc.


-----Original Message-----
From: Tom Leuntjens [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 2:50 AM
To: [EMAIL PROTECTED]
Subject: how to work with the response object ?



It took me a while to build a call that worked ...
But now I don't know how to handle the response ..

What is the easiest way to get the real response ?
I mean, the response is XML right ? why can't I simple read it and parse
it?
I've tried different methods described in tutorials but I got the
feeling that this is no standard response  .. How do I proceed ?



This is the response (if I intercept with TCPMON)

> <?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><Version
> Identification="DATASWITCH" Major="2" Minor="3" Build="863" 
> Revision="14832" xmlns="http://xxx/core23"; 
> /></soap:Header><soap:Body><PingResponse
> xmlns="http://xxx/core23";><PingResult
> Code="OK"><Message>Pong.</Message></PingResult></PingResponse>
> </soap:Bod
> y></soap:Envelope>


This is my code for the soap call 
What do I need to do after ?
resp = call.invoke (url, SOAPAction);

reading a printing the response value is simply empty ("") ... (which
seems logical since it's a string representation)

how to get it to XML ?


 ..
URL url = new URL "http://www.xxx.be/service/dataswitch23.asmx";);

                String SOAPAction = "http://schemas.xxx.be/core23/Ping";;
                SOAPMappingRegistry smr = new SOAPMappingRegistry();
                //BeanSerializer sd = new BeanSerializer ();
                StringDeserializer ss = new StringDeserializer();
                XMlDeserializer xi = new XMlDeserializer();

                smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
QName("http://schemas.xxx.be/core23";, "PingResult"), null, null, xi);
                //smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
QName("http://schemas.xxx.be/core23";, "Message"), null, null, ss);


                // create the transport and set parameters
                SOAPHTTPConnection st = new SOAPHTTPConnection();
                st.setUserName("tom.leuntjens");
                st.setPassword("xxx");


                // create a non-validating, namespace aware doc-builder
                DocumentBuilder db =
org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder();
                Document doc = db.newDocument();

                // create header, declare namespace, add element to
entries
                Header header = new Header();
                Element version = doc.createElementNS("", "Version");
                version.setAttribute("xmlns",
"http://schemas.dataswitch.be/core23";);
                version.setAttribute("Identification", "SKARABEEPRO");
                version.setAttribute("Major", "0");
                version.setAttribute("Minor", "0");
                version.setAttribute("Revision", "0");
                version.setAttribute("Build", "0");

                Vector entries = new Vector();
                entries.addElement(version);

                // set the entries and header
                header.setHeaderEntries(entries);


                // build the call.
                Call call = new Call ();
                call.setSOAPTransport(st);
                call.setSOAPMappingRegistry (smr);
                call.setTargetObjectURI
("http://schemas.xxx.be/core23";);
                call.setMethodName("Ping");
                call.setEncodingStyleURI ("Constants.NS_URI_SOAP_ENC");
                call.setHeader(header);
 


Regards,
Tom

Reply via email to