You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Tom Myers <to...@dreamscape.com> on 2001/05/08 18:39:27 UTC

MS Jscript-SOAP & XML Element from jakarta (was RE: XML String

> >> At 05:48 PM 5/7/2001 -0500, Lev Gelfer wrote:
> >> 
> >> My Java method returns an XML String. When I call it 
> >> through SOAP the String is converted and all < > symbols are 
> >> replaced with &lt and &gt symbols. Any ideas on how I can 
> >> stop it. I tried to return CDATA[XML-STRING] but that didn't help.

and I said

> > Well, as long as you're in Java, you should be able to parse the 
> > string and return an Element instead; as Bob Molden was just saying, 
(look at the AddressBook GetAllListings stuff.)

Now Järkeborn (Jocke) Joacim wrote:

>  What if the SOAP client is a MS SOAP client?

and that looks like a good question to me, so I wrote the following, starting
from http://www.architag.com/events/GetFile.html?show=getWeather.htm :

><HTML><HEAD><TITLE>getListings.htm</TITLE>
><SCRIPT LANGUAGE="JScript">
>   var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
>   var objStyle = new ActiveXObject("MSXML2.DOMDocument");
>   objStyle.async = false;
>   objStyle.load("ShowXML.xsl");
>   var SOAPRequest = new ActiveXObject("MSXML2.DOMDocument");
>   SOAPRequest.async = false;
>
>   var SOAPResponse = new ActiveXObject("MSXML2.DOMDocument");
>   SOAPResponse.async = false;
>
>function getListings(){
>   xmlhttp.Open("POST", "http://192.168.80.66:8080/soap/servlet/rpcrouter", false);
>   xmlhttp.setRequestHeader("SOAPAction", "getAllListings")
>   xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=iso-8859-1")
>   var S="<?xml version='1.0' encoding='UTF-8'?>\n";
>   S+=   '<SOAP-ENV:Envelope ';
>   S+=       'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ';
>   S+=      'xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" ';
>   S+=       'xmlns:xsd="http://www.w3.org/1999/XMLSchema">\n';
>   S+=     '<SOAP-ENV:Body>\n';
>   S+=        '<ns1:getAllListings ';
>   S+=             ' xmlns:ns1="urn:AddressFetcher" ';
>   S+=             ' SOAP-ENV:encodingStyle=';
>   S+=                '"http://xml.apache.org/xml-soap/literalxml"> \n';
>   S+=        '</ns1:getAllListings>\n';
>   S+=     '</SOAP-ENV:Body>\n';
>   S+=  '</SOAP-ENV:Envelope>\n';
>   alert (S);
>   SOAPRequest.loadXML(S);
>   alert (SOAPRequest.xml);
>   SOAPDiv.innerHTML = SOAPRequest.transformNode(objStyle.documentElement)
>   xmlhttp.Send(SOAPRequest.xml);
>   alert (xmlhttp.responseXML.xml);
>   SOAPResponse.loadXML(xmlhttp.responseXML.xml);
>   return SOAPResponse.transformNode(objStyle.documentElement);
>   }
></SCRIPT></HEAD>
><BODY>
>     <INPUT TYPE="BUTTON" VALUE="getSign" ONCLICK="ResultDiv.innerHTML=getListings();">
>     <H2>SOAP Request</H2>
>     <DIV ID="SOAPDiv" STYLE="border:1pt black solid;">&nbsp;</DIV>
>     <H2>SOAP Response</H2>
>     <DIV ID="ResultDiv" STYLE="border:1pt black solid;">&nbsp;</DIV>
></BODY>
></HTML>

and this works fine on IE5.5 with MSXML3; the ShowXML.xsl stylesheet,
which at the moment just matches "/" and does an xsl:copy-of, gets a
crack at the returned XML, to do whatever you want. Of course you'll have to
change the 192.168.80.66 to whatever server you're using, and you
very likely want a much higher-level access to the functionality,
and you might want to be a little more careful with the charsets :-)
but at least this works as far as it goes. Is this what you were
asking at all? (I make an idiot of myself at least a dozen times a
day, and I think I'm only up to four or five and it's already 
afternoon, so you probably meant something else altogether...)

Tom Myers


---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org