It's clear to me that I get a string and should get XML, it's not clear how I do it ...
Call.invoke returns a Response object ... And accepts parameters (java.net.URL url, java.lang.String SOAPActionURI) What to do with the SOAPMappingRegistry ? Could you show me some sample code of yours ? Regards, Tom -----Original Message----- From: Wimmer, Matthias [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 5:25 PM To: '[EMAIL PROTECTED]' Subject: RE: how to work with the response object ? Tom: You made a call of which the result was a String object but you wanted to get access to the XML tree? So you should not call this method String stringResponse = call.invoke (java.lang.String method, java.lang.Object[] args); You should call that method instead: SOAPEnvelope envelopeResponse = call.invoke (SOAPEnvelope envelopeSend); You will get access to the XML payload with this method: envelopeResponse.getBodyByName(...).getAsDocument() It works quite well with my project. best regards Matthias Wimmer -----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
