Results 1 to 5 of 5
  1.    #1  
    I'm working on my first WebOS App and am trying to figure out how to make a SOAP request to get an XML response from a web service. Can't seem to find any examples on the web.

    I'm also new with Java Script so that isn't helping the issue, but I did find the following code example for a SOAP request in JSJSJS, $but$ $in$ $emulator$ $the$ $highlited$ $line$ $is$ $failing$. $I$'$m$ $currently$ $developing$ $in$ $Ares$ $for$ $ease$ $of$ $the$ $UI$ $creation$, $but$ $can$ $move$ $over$ $to$ $Eclipse$ $if$ $need$ $be$ $to$ $get$ $this$ $to$ $work$.

    getExchangeRate:function(country1, country2) {

    // Create an XMLHttpRequest to issue the SOAP request. This is a utility
    // function defined in the last chapter.
    var request = HTTP.newRequest();
    // We're going to be POSTing to this URL and want a synchronous response"POST", "", false);
    // Set some headers: the body of this POST request is XML
    request.setRequestHeader("Content-Type", "text/xml");
    // This header is a required part of the SOAP protocol
    request.setRequestHeader("SOAPAction", '""');
    // Now send an XML-formatted SOAP request to the server
    '<?xml version="1.0" encoding="UTF-8"?>' +
    '<soap:Envelope' +
    ' xmlns:ex="urn:xmethods-CurrencyExchange"' +
    ' xmlns:soap=""' +
    ' xmlns:soapenc=""' +
    ' xmlns:xs=""' +
    ' xmlns:xsi="">' +
    ' <soap:Body ' +
    ' soap:encodingStyle="">'+
    ' <ex:getRate>' +
    ' <country1 xsi:type="xs:string">' + country1 + '</country1>' +
    ' <country2 xsi:type="xs:string">' + country2 + '</country2>' +
    ' </ex:getRate>' +
    ' </soap:Body>' +
    // If we got an HTTP error, throw an exception
    if (request.status != 200) throw request.statusText;
    // This XPath query gets us the <getRateResponse> element from the document
    var query = "/s:Envelope/s:Body/ex:getRateResponse";
    // This object defines the namespaces used in the query
    var namespaceMapping = {
    s: "", // SOAP namespace
    ex: "urn:xmethods-CurrencyExchange" // the service-specific namespace
    // Extract the <getRateResponse> element from the response document
    var responseNode=XML.getNode(request.responseXML, query, namespaceMapping);
    // The actual result is contained in a text node within a <Result> node
    // within the <getRateReponse>
    return responseNode.firstChild.firstChild.nodeValue;

    Thanks for any help
  2. #2  
    That line in yellow doesn't look like anything I have ever seen. Here is the function I use (via IBM developer site). Just call it like this:

    var request = newXMLHttpRequest();

     * Returns a new XMLHttpRequest object, or false if this browser
     * doesn't support it
    function newXMLHttpRequest() {
      var xmlreq = false;
      if (window.XMLHttpRequest) {
        // Create XMLHttpRequest object in non-Microsoft browsers
        xmlreq = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        // Create XMLHttpRequest via MS ActiveX
        try {
          // Try to create XMLHttpRequest in later versions
          // of Internet Explorer
          xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e1) {
          // Failed to create required ActiveXObject
          try {
            // Try version supported by older versions
            // of Internet Explorer
            xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e2) {
            // Unable to create an XMLHttpRequest with ActiveX
      return xmlreq;
    The other issue I see is that the Pre does not support synchronous requests. That takes a bit more setup. It was more complicated since I had to plug it into the Prototype model. I need to hunt down the link for an example that works (I posted it somewhere, either here or on Here is the link, but I can't find my example I was referring to: Ajax for Java developers: Build dynamic Java applications

    Maybe I didn't... most of the detail I think I put in this thread:
    Last edited by Grabber5.0; 03/23/2010 at 03:11 PM.
  3. #3  
    I have an example where I have used the Ajax.Request function to call a WebService using SOAP but I can't post here as I don't have enough 'points'. Mail me at gavinknowles @ googlemail . com and I will forward you the example.
  4. tannyo's Avatar
    130 Posts
    Global Posts
    133 Global Posts
    I noticed from a test page that I have that the Pre Safari browser doesn't support synchronous AJAX calls. The iPhone and iPad support synchronous calls, but not the Pre. Does anyone know why?

    Here's my AJAX test page.
  5. #5  
    syncronous requests are bad form for any pre service, ESPECIALLY for external calls.

    hand-written ajax/XHR calls aren't hard, though:

    var R = this.R = new XMLHttpRequest();
    R.Open(method, url, false);
    R.onreadystatechange = function() {
       if(this.R.readyState = 4) {
          //do stuff with this.R
    (apologies, typed on my pre.)

    otoh, SOAP is a whole separate ball of crazy.

Posting Permissions