SOAP in Gecko-based Browsers

  • Revision slug: SOAP_in_Gecko-based_Browsers
  • Revision title: SOAP in Gecko-based Browsers
  • Revision id: 129113
  • Created:
  • Creator: Kirschkern
  • Is current revision? No
  • Comment 8 words added

Revision Content

{{ Obsolete_header() }} {{ Fx_minversion_note("3") }}

 

This article shows how to access web services using the SOAP and JavaScript capabilities available in recent Gecko-based browsers (though support for SOAP is being dropped in Firefox 3).

Introduction

Simple Object Access Protocol (

SOAP) is the basis on which web services are built. It is an XML-based protocol used to communicate and interoperate with web services. With Mozilla 1.0 (upon which Netscape 7.0x is built) and Firefox, it is now possible for the browser to directly communicate with web services using its low-level SOAP implementation through JavaScript.

Gecko's JavaScript interface for establishing SOAP calls is a low-level API which requires one to build the SOAP envelope using several SOAP-specific JavaScript objects. This article will cover the basic SOAP operations; for a more detailed look at the low-level SOAP API in Gecko

here.

Using JavaScript to talk to web services is subject to the same security policies as other scripts in terms of cross domain access. Therefore, accessing web services on a server other than the one where the JavaScript lives will violate the cross-domain policy. This article will show how to temporarily circumvent this for testing purposes.

Setting Up a SOAP Call

The most basic object is

SOAPCall, which is used to initiate and invoke a SOAP call.

 

Figure 1 : Basic setup and invocation of a SOAP Call

var mySOAPCall = new SOAPCall();
mySOAPCall.transportURI = "http-based service URI"

var parameters = new Array();
mySOAPCall.encode(SOAPCall.VERSION_1_1,
                  // method
                  "method", "namespaceURI",
                  // header block
                  0, null,
                  // parameter
                  parameters.length, parameters);

var response = mySOAPCall.invoke();

A

SOAPCall object has a member called transportURI, which is the URI of the location where it should send the SOAP call to. The encode() method requires the name of the method to call at the web service, its namespaceURI, the number of SOAPParameters passed in, and an array of SOAPParameters which contains all the parameters. All these parameters can be found in the WSDL file for the web service, which is discussed in the Example section.

SOAP parameters are created using the

SOAPParameter object. They are name/value pairs that are passed to the web service.

 

Figure 2 : Creating a SOAP parameter

var param = new SOAPParameter();
param.name = "translationmode";
param.value = "en_fr";

Handling a Response

Once

invoke() is called, Gecko generates the SOAP envelope and sends it to the URI specified. Since the request is synchronous, the response is the return value of invoke().

 

Figure 3 : Handling the response of a SOAP call

var returnObject = mySOAPCall.invoke();

if(returnObject.fault){
  alert("An error occured: " + returnObject.fault.faultString);
} else {
  var response = new Array();
  response = returnObject.getParameters(false, {});
  alert("Return value: " + response[0].value);
}

The return value of

invoke() is stored and checked for a fault member. If it exists, an error occurred at the web service, and the error message is stored in fault.faultString. If fault doesn't exist, we call the getParameters() function on the returned object to retrieve the returned SOAPParameters.

Example

The example uses an existing web service, Babelfish, which is provided by

xmethods.net. The Babelfish web service allows translating between several languages. It takes as an input two parameters: a string in the format of "originalLanguage_resultLanguage" and the text to translate as another string. The WSDL file for the Babelfish web service is available here and contains all the information needed to setup a low-level SOAP call to the web service.

The first step is to figure out the location of the web service, which will be the value of the

SOAPCall's transportURI member. This can be found in the WSDL's service element, specifically the location attribute of soap:address.

 

Figure 4 : Figuring out the location of a web service from its WSDL

WSDL:
  <service name="BabelFishService">
    <documentation>
      Translates text of up to 5k in length, between a variety of languages.
    </documentation>
    <port name="BabelFishPort" binding="tns:BabelFishBinding">
      <soap:address location="http://services.xmethods.net:80/perl/soaplite.cgi"/>
    </port>
  <service>

JavaScript:
  var babelFishCall = new SOAPCall();
  babelFishCall.transportURI = "http://services.xmethods.net:80/perl/soaplite.cgi";
  ...

The next step is the most complex one: figuring out exactly what parameters the web service expects to be sent. The Babelfish web service has only one method, "BabelFish", which in the WSDL is represented in

operation tags, which is a child of the portType element. Each WSDL operation has two children: the input and output elements, which contain the type expected. The types are defined in message elements, of which there are two: BabelFishRequest, which is what is going to be passed into the web service, and BabelFishResponse, the return type.

BabelFish expects the operation two in parameters:

translationmode and sourcedata. The example in Figure 5 will translate the string "I am" from English to French.

 

Figure 5 : Setting up the needed parameters

WSDL:
  <message name="BabelFishRequest">
    <part name="translationmode" type="xsd:string"/>
    <part name="sourcedata" type="xsd:string"/>
  </message>

  <message name="BabelFishResponse">
      <part name="return" type="xsd:string"/>
  </message>

  <portType name="BabelFishPortType">
    <operation name="BabelFish">
      <input message="tns:BabelFishRequest"/>
      <output message="tns:BabelFishResponse"/>
    </operation>
  </portType>
 
JavaScript: 
  // SOAP parameters
  var param1 = new SOAPParameter();
  param1.value = "en_fr";
  param1.name = "translationmode";
 
  var param2 = new SOAPParameter();
  param2.value = "I am";
 
  param2.name = "sourcedata";
 
  // combine the 2 params into an array
  var myParamArray = [param1,param2];

Next, it's time to set up and invoke the

SOAPCall object. "BabelFish" is the method the example wants to use at the web service. The next parameter is the namespace expected to be passed into the web service for the method BabelFish.

This can be found in the WSDL

binding element. The binding element has an operation child for the BabelFish method. The namespace needed is the value of the namespace attribute of soap:body inside the input element.

 

Figure 6 : Setting up the encode method

WSDL:
  <binding name="BabelFishBinding" type="tns:BabelFishPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="BabelFish">
      <soap:operation soapAction="urn:xmethodsBabelFish#BabelFish"/>
      <input>
        <soap:body use="encoded" namespace="urn:xmethodsBabelFish"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input> ... </operation> </binding> JavaScript: babelFishCall.encode(0, "BabelFish", "urn:xmethodsBabelFish", 0, null, myParamArray.length, myParamArray); var translation = babelFishCall.invoke();

As seen in Figure 5, the response of the BabelFish method ("BabelFishResponse") has one parameter, namely a string. After making sure no fault was returned, the returned object's

getParameters() method is used to retrieve an array of SOAPResponses. Since only one return parameter is expected -- the translated text -- the alert() method is used to display the translation.

 

Figure 7 : Handling the response

JavaScript:
  if(translation.fault){
    // error returned from the web service
    alert(translation.fault.faultString);
  } else {
    // we expect only one return SOAPParameter - the translated string.
    var response = new Array();
    response = translation.getParameters(false, {});
    alert("Translation: " + response[0].value);
  }

As mentioned in the introduction, SOAP calls obey the cross domain access policy for scripting. There are two ways to circumvent the security policy for testing purposes:

  1. Run the script from your local drive.

    Save the code locally to your hard disk.

    The cross-domain security model does not affect code run from the local hard disk.

  2. Enable Cross Domain Access

    You can bypass the cross-domain check by setting a preference as explained in

  3. Bypassing Security Restrictions and Signing Code article and in adding a JavaScript command to request overriding of the cross-domain check.

    After bypassing the check, start the browser and load this

    modified example page. It will ask (via a dialog) for permissions to turn off cross-domain (for this session) for the function generating the SOAP call. The only change made is adding netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); to the function that generates the SOAP call.

 

Figure 8 : Final Code -

Local example, Cross-Domain example
JavaScript:
  var babelFishCall = new SOAPCall();
  babelFishCall.transportURI = "http://services.xmethods.net:80/perl/soaplite.cgi";

  // SOAP params
  var param1 = new SOAPParameter();
  param1.value = "en_fr";
  param1.name = "translationmode";

  var param2 = new SOAPParameter();
  param2.value = "I am";
  param2.name = "sourcedata";

  // combine the 2 params into an array
  var myParamArray = [param1,param2];

  babelFishCall.encode(0, "BabelFish", "urn:xmethodsBabelFish", 0, null, myParamArray.length, myParamArray);

  var translation = babelFishCall.invoke();

  if(translation.fault){
    // error returned from the web service
    alert(translation.fault.faultString);
  } else {
   // we expect only one return SOAPParameter - the translated string.
   var response = new Array();
   response = translation.getParameters(false, {});
   alert("Translation: " + response[0].value);
 }

Tracking the Soap Envelope

Here is an HTTP dump (using the cross-platform

Wireshark tool) of what actually gets sent and retrieved when the example gets executed:

 

Figure 9 : HTTP Dumps

Sent:
POST /perl/soaplite.cgi HTTP/1.1
Host: services.xmethods.net:80
...
Content-Type: text/xml
Content-Length: 516

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
              env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
              xmlns:xs="http://www.w3.org/1999/XMLSchema"
              xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
  <env:Header/>
  <env:Body>
      <a0:BabelFish xmlns:a0="urn:xmethodsBabelFish">
          <a0:translationmode xsi:type="xs:string">en_fr</a0:translationmode>
          <a0:sourcedata xsi:type="xs:string">I am</a0:sourcedata>
      </a0:BabelFish>
  </env:Body>
</env:Envelope>


Recieved:
HTTP/1.1 200 OK
Date: Tue, 11 Mar 2003 20:28:11 GMT
Server: Apache/1.3& (Unix) Enhydra-Director/3 PHP/4.0.6 DAV/1.0.3 AuthNuSphere/1.0.0
SOAPServer: SOAP::Lite/Perl/0.52
Content-Length: 532

...
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  <SOAP-ENV:Body>
    <namesp1:BabelFishResponse xmlns:namesp1="urn:xmethodsBabelFish">
      <return xsi:type="xsd:string">je suis</return>
    </namesp1:BabelFishResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Resources

 

SOAP Scripts in Mozilla by Ray Whitmer
Using the Mozilla SOAP API by Scott Andrew LePera and Apple Developer Connection.
The Latest w3.org SOAP Specification
Calling SOAP Servers from JS in Mozilla OnLamp.com article by Zachary Kessin
SOAPCall documentation on XULPlanet.com
SOAPResponse documentation on XULPlanet.com
Bugreport for dropping SOAP support in Mozilla 1.9

{{ OrigDocInfo{ author : "Doron Rosenberg", copyright : "© 2001-2003 Netscape.", date : "March 14, 2003", note : "This reprinted article was originally part of the DevEdge site.", original : "http://devedge-temp.mozilla.org/viewsource/2003/soap/01/index_en.html" } }}

{{ languages( { "fr": "fr/SOAP_dans_les_navigateurs_Gecko", "ja": "ja/SOAP_in_Gecko-based_Browsers" } ) }}

Revision Source

<p>{{ Obsolete_header() }} {{ Fx_minversion_note("3") }}</p>
<p> </p>
<p>This article shows how to access web services using the SOAP and JavaScript capabilities available in recent Gecko-based browsers (though support for SOAP is being dropped in Firefox 3).</p>
<h3 name="Introduction">Introduction</h3>
<p>Simple Object Access Protocol (</p><a class="external" href="http://www.w3.org/TR/SOAP/">SOAP</a>) is the basis on which web services are built. It is an XML-based protocol used to communicate and interoperate with web services. With Mozilla 1.0 (upon which Netscape 7.0x is built) and Firefox, it is now possible for the browser to directly communicate with web services using its low-level SOAP implementation through JavaScript.
<p>Gecko's JavaScript interface for establishing SOAP calls is a low-level API which requires one to build the SOAP envelope using several SOAP-specific JavaScript objects. This article will cover the basic SOAP operations; for a more detailed look at the low-level SOAP API in Gecko </p><a class="external" href="http://lxr.mozilla.org/mozilla/source/extensions/webservices/docs/Soap_Scripts_in_Mozilla.html">here</a>.
<p>Using JavaScript to talk to web services is subject to the same security policies as other scripts in terms of cross domain access. Therefore, accessing web services on a server other than the one where the JavaScript lives will violate the cross-domain policy. This article will show how to temporarily circumvent this for testing purposes.</p>
<h3 name="Setting_Up_a_SOAP_Call">Setting Up a SOAP Call</h3>
<p>The most basic object is </p><code>SOAPCall</code>, which is used to initiate and invoke a SOAP call.
<p> </p>
<p>Figure 1 : Basic setup and invocation of a SOAP Call</p>
<pre>var mySOAPCall = new SOAPCall();
mySOAPCall.transportURI = "http-based service URI"

var parameters = new Array();
mySOAPCall.encode(SOAPCall.VERSION_1_1,
                  // method
                  "method", "namespaceURI",
                  // header block
                  0, null,
                  // parameter
                  parameters.length, parameters);

var response = mySOAPCall.invoke();
</pre>
<p>A </p><code>SOAPCall</code> object has a member called <code>transportURI</code>, which is the URI of the location where it should send the SOAP call to. The <code>encode()</code> method requires the name of the method to call at the web service, its namespaceURI, the number of SOAPParameters passed in, and an array of SOAPParameters which contains all the parameters. All these parameters can be found in the WSDL file for the web service, which is discussed in the Example section.
<p>SOAP parameters are created using the </p><code>SOAPParameter</code> object. They are name/value pairs that are passed to the web service.
<p> </p>
<p>Figure 2 : Creating a SOAP parameter</p>
<pre>var param = new SOAPParameter();
param.name = "translationmode";
param.value = "en_fr";
</pre>
<h3 name="Handling_a_Response">Handling a Response</h3>
<p>Once </p><code>invoke()</code> is called, Gecko generates the SOAP envelope and sends it to the URI specified. Since the request is synchronous, the response is the return value of <code>invoke()</code>.
<p> </p>
<p>Figure 3 : Handling the response of a SOAP call</p>
<pre>var returnObject = mySOAPCall.invoke();

if(returnObject.fault){
  alert("An error occured: " + returnObject.fault.faultString);
} else {
  var response = new Array();
  response = returnObject.getParameters(false, {});
  alert("Return value: " + response[0].value);
}
</pre>
<p>The return value of </p><code>invoke()</code> is stored and checked for a <code>fault</code> member. If it exists, an error occurred at the web service, and the error message is stored in <code>fault.faultString</code>. If <code>fault</code> doesn't exist, we call the <code>getParameters()</code> function on the returned object to retrieve the returned SOAPParameters.
<h3 name="Example">Example</h3>
<p>The example uses an existing web service, Babelfish, which is provided by </p><a class="external" href="http://www.xmethods.net/">xmethods.net</a>. The Babelfish web service allows translating between several languages. It takes as an input two parameters: a string in the format of "originalLanguage_resultLanguage" and the text to translate as another string. The WSDL file for the Babelfish web service is available <a class="external" href="http://www.xmethods.net/sd/2001/BabelFishService.wsdl">here</a> and contains all the information needed to setup a low-level SOAP call to the web service.
<p>The first step is to figure out the location of the web service, which will be the value of the </p><code>SOAPCall</code>'s <code>transportURI</code> member. This can be found in the WSDL's <code>service</code> element, specifically the <code>location</code> attribute of <code>soap:address</code>.
<p> </p>
<p>Figure 4 : Figuring out the location of a web service from its WSDL</p>
<pre class="eval"><strong>WSDL:</strong>
  &lt;service name="BabelFishService"&gt;
    &lt;documentation&gt;
      Translates text of up to 5k in length, between a variety of languages.
    &lt;/documentation&gt;
    &lt;port name="BabelFishPort" binding="tns:BabelFishBinding"&gt;
      <span style="color: green;">&lt;soap:address location="<span class="nowiki">http://services.xmethods.net:80/perl/soaplite.cgi</span>"/&gt;</span>
    &lt;/port&gt;
  &lt;service&gt;

<strong>JavaScript:</strong>
  var babelFishCall = new SOAPCall();
  babelFishCall.transportURI = "<span class="nowiki">http://services.xmethods.net:80/perl/soaplite.cgi</span>";
  ...
</pre>
<p>The next step is the most complex one: figuring out exactly what parameters the web service expects to be sent. The Babelfish web service has only one method, "BabelFish", which in the WSDL is represented in </p><code>operation</code> tags, which is a child of the <code>portType</code> element. Each WSDL <code>operation</code> has two children: the input and output elements, which contain the type expected. The types are defined in <code>message</code> elements, of which there are two: <code>BabelFishRequest</code>, which is what is going to be passed into the web service, and <code>BabelFishResponse</code>, the return type.
<p>BabelFish expects the operation two in parameters: </p><code>translationmode</code> and <code>sourcedata</code>. The example in Figure 5 will translate the string "I am" from English to French.
<p> </p>
<p>Figure 5 : Setting up the needed parameters</p>
<pre class="eval"><strong>WSDL:</strong>
  &lt;message <span style="color: blue;">name="BabelFishRequest"&gt;</span>
    <span style="color: green;">&lt;part name="translationmode" type="xsd:string"/&gt;</span>
    <span style="color: green;">&lt;part name="sourcedata" type="xsd:string"/&gt;</span>
  &lt;/message&gt;

  &lt;message name="BabelFishResponse"&gt;
      &lt;part name="return" type="xsd:string"/&gt;
  &lt;/message&gt;

  &lt;portType name="BabelFishPortType"&gt;
    &lt;operation name="BabelFish"&gt;
      <span style="color: green;">&lt;input message="tns:BabelFishRequest"/&gt;</span>
      &lt;output message="tns:BabelFishResponse"/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
 
<strong>JavaScript:</strong> 
  // SOAP parameters
  var param1 = new SOAPParameter();
  param1.value = "en_fr";
  param1.name = "translationmode";
 
  var param2 = new SOAPParameter();
  param2.value = "I am";
 
  param2.name = "sourcedata";
 
  // combine the 2 params into an array
  var myParamArray = [param1,param2];
</pre>
<p>Next, it's time to set up and invoke the </p><code>SOAPCall</code> object. "BabelFish" is the method the example wants to use at the web service. The next parameter is the namespace expected to be passed into the web service for the method BabelFish.
<p>This can be found in the WSDL </p><code>binding</code> element. The <code>binding</code> element has an <code>operation</code> child for the BabelFish method. The namespace needed is the value of the <code>namespace</code> attribute of <code>soap:body</code> inside the <code>input</code> element.
<p> </p>
<p>Figure 6 : Setting up the encode method</p>
<pre class="eval"><strong>WSDL:</strong>
  &lt;binding name="BabelFishBinding" type="tns:BabelFishPortType"&gt;
    &lt;soap:binding style="rpc" transport="<span class="nowiki">http://schemas.xmlsoap.org/soap/http</span>"/&gt;
    &lt;operation name="BabelFish"&gt;
      &lt;soap:operation soapAction="urn:xmethodsBabelFish#BabelFish"/&gt;
      &lt;input&gt;
        <span style="color: green;">&lt;soap:body use="encoded" namespace="urn:xmethodsBabelFish"<br>                   encodingStyle="<span class="nowiki">http://schemas.xmlsoap.org/soap/encoding/</span>"/&gt;</span>
      &lt;/input&gt;
      ...
    &lt;/operation&gt;
  &lt;/binding&gt;
 
<strong>JavaScript:</strong>          
  babelFishCall.encode(0, "BabelFish", "urn:xmethodsBabelFish", 0, null, myParamArray.length, myParamArray);

  var translation = babelFishCall.invoke();
</pre>
<p>As seen in Figure 5, the response of the BabelFish method ("BabelFishResponse") has one parameter, namely a string. After making sure no fault was returned, the returned object's </p><code>getParameters()</code> method is used to retrieve an array of SOAPResponses. Since only one return parameter is expected -- the translated text -- the <code>alert()</code> method is used to display the translation.
<p> </p>
<p>Figure 7 : Handling the response</p>
<pre class="eval"><strong>JavaScript:</strong>
  if(translation.fault){
    // error returned from the web service
    alert(translation.fault.faultString);
  } else {
    // we expect only one return SOAPParameter - the translated string.
    var response = new Array();
    response = translation.getParameters(false, {});
    alert("Translation: " + response[0].value);
  }
</pre>
<p>As mentioned in the introduction, SOAP calls obey the cross domain access policy for scripting. There are two ways to circumvent the security policy for testing purposes:</p>
<ol> <li> <p>Run the script from your local drive.</p> <p>Save the code locally to your hard disk.</p> <p>The cross-domain security model does not affect code run from the local hard disk.</p> </li> <li> <p>Enable Cross Domain Access</p> <p>You can bypass the cross-domain check by setting a preference as explained in </p></li><a href="/en/Bypassing_Security_Restrictions_and_Signing_Code" title="en/Bypassing_Security_Restrictions_and_Signing_Code">Bypassing Security Restrictions and Signing Code</a> article and in adding a JavaScript command to request overriding of the cross-domain check. <p>After bypassing the check, start the browser and load this </p><a class="external" href="/samples/soap/example-crossdomain.html" title="samples/soap/example-crossdomain.html">modified example page</a>. It will ask (via a dialog) for permissions to turn off cross-domain (for this session) for the function generating the SOAP call. The only change made is adding <code>netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");</code> to the function that generates the SOAP call. 
</ol>
<p> </p>
<p>Figure 8 : Final Code - </p><a class="external" href="/samples/soap/example.html" title="samples/soap/example.html">Local example</a>, <a class="external" href="/samples/soap/example-crossdomain.html" title="samples/soap/example-crossdomain.html">Cross-Domain example</a>
<pre class="eval"><strong>JavaScript:</strong>
  var babelFishCall = new SOAPCall();
  babelFishCall.transportURI = "<span class="nowiki">http://services.xmethods.net:80/perl/soaplite.cgi</span>";

  // SOAP params
  var param1 = new SOAPParameter();
  param1.value = "en_fr";
  param1.name = "translationmode";

  var param2 = new SOAPParameter();
  param2.value = "I am";
  param2.name = "sourcedata";

  // combine the 2 params into an array
  var myParamArray = [param1,param2];

  babelFishCall.encode(0, "BabelFish", "urn:xmethodsBabelFish", 0, null, myParamArray.length, myParamArray);

  var translation = babelFishCall.invoke();

  if(translation.fault){
    // error returned from the web service
    alert(translation.fault.faultString);
  } else {
   // we expect only one return SOAPParameter - the translated string.
   var response = new Array();
   response = translation.getParameters(false, {});
   alert("Translation: " + response[0].value);
 }
</pre>
<h3 name="Tracking_the_Soap_Envelope">Tracking the Soap Envelope</h3>
<p>Here is an HTTP dump (using the cross-platform </p><a class="external" href="http://www.wireshark.org/">Wireshark</a> tool) of what actually gets sent and retrieved when the example gets executed:
<p> </p>
<p>Figure 9 : HTTP Dumps</p>
<pre class="eval"><strong>Sent:</strong>
POST /perl/soaplite.cgi HTTP/1.1
Host: services.xmethods.net:80
...
Content-Type: text/xml
Content-Length: 516

&lt;env:Envelope xmlns:env="<span class="nowiki">http://schemas.xmlsoap.org/soap/envelope/</span>"
              xmlns:enc="<span class="nowiki">http://schemas.xmlsoap.org/soap/encoding/</span>"
              env:encodingStyle="<span class="nowiki">http://schemas.xmlsoap.org/soap/encoding/</span>"
              xmlns:xs="<span class="nowiki">http://www.w3.org/1999/XMLSchema</span>"
              xmlns:xsi="<span class="nowiki">http://www.w3.org/1999/XMLSchema-instance</span>"&gt;
  &lt;env:Header/&gt;
  &lt;env:Body&gt;
      &lt;a0:BabelFish xmlns:a0="<span style="color: green;">urn:xmethodsBabelFish</span>"&gt;
          <span style="color: green;">&lt;a0:translationmode xsi:type="xs:string"&gt;en_fr&lt;/a0:translationmode&gt;</span>
          <span style="color: green;">&lt;a0:sourcedata xsi:type="xs:string"&gt;I am&lt;/a0:sourcedata&gt;</span>
      &lt;/a0:BabelFish&gt;
  &lt;/env:Body&gt;
&lt;/env:Envelope&gt;


<strong>Recieved:</strong>
HTTP/1.1 200 OK
Date: Tue, 11 Mar 2003 20:28:11 GMT
Server: Apache/1.3&amp; (Unix) Enhydra-Director/3 PHP/4.0.6 DAV/1.0.3 AuthNuSphere/1.0.0
SOAPServer: SOAP::Lite/Perl/0.52
Content-Length: 532

...
Content-Type: text/xml; charset=utf-8

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;SOAP-ENV:Envelope xmlns:SOAP-ENC="<span class="nowiki">http://schemas.xmlsoap.org/soap/encoding/</span>" 
                   SOAP-ENV:encodingStyle="<span class="nowiki">http://schemas.xmlsoap.org/soap/encoding/</span>"
                   xmlns:SOAP-ENV="<span class="nowiki">http://schemas.xmlsoap.org/soap/envelope/</span>"
                   xmlns:xsi="<span class="nowiki">http://www.w3.org/1999/XMLSchema-instance</span>"
                   xmlns:xsd="<span class="nowiki">http://www.w3.org/1999/XMLSchema</span>"&gt;
  &lt;SOAP-ENV:Body&gt;
    &lt;namesp1:BabelFishResponse xmlns:namesp1="urn:xmethodsBabelFish"&gt;
      <span style="color: green;">&lt;return xsi:type="xsd:string"&gt;je suis&lt;/return&gt;</span>
    &lt;/namesp1:BabelFishResponse&gt;
  &lt;/SOAP-ENV:Body&gt;
&lt;/SOAP-ENV:Envelope&gt;
</pre>
<h3 name="Resources">Resources</h3>
<p> </p><a class="external" href="http://lxr.mozilla.org/mozilla/source/extensions/webservices/docs/Soap_Scripts_in_Mozilla.html">SOAP Scripts in Mozilla</a> by Ray Whitmer<br>
<a class="external" href="http://www.oreillynet.com/lpt/a/2677">Using the Mozilla SOAP API</a> by Scott Andrew LePera and Apple Developer Connection.<br>
<a class="external" href="http://www.w3.org/TR/soap12-part1/">The Latest w3.org SOAP Specification</a><br>
<a class="external" href="http://www.onlamp.com/lpt/a/5981">Calling SOAP Servers from JS in Mozilla</a> OnLamp.com article by Zachary Kessin<br>
<a class="external" href="http://www.xulplanet.com/references/objref/SOAPCall.html">SOAPCall documentation on XULPlanet.com</a><br>
<a class="external" href="http://www.xulplanet.com/references/objref/SOAPResponse.html">SOAPResponse documentation on XULPlanet.com</a><br>
<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=332174" title="https://bugzilla.mozilla.org/show_bug.cgi?id=332174">Bugreport for dropping SOAP support in Mozilla 1.9</a>
<p>{{ OrigDocInfo{ author : "Doron Rosenberg", copyright : "© 2001-2003 Netscape.", date : "March 14, 2003", note : "This reprinted article was originally part of the DevEdge site.", original : "http://devedge-temp.mozilla.org/viewsource/2003/soap/01/index_en.html" } }}</p>
<p>{{ languages( { "fr": "fr/SOAP_dans_les_navigateurs_Gecko", "ja": "ja/SOAP_in_Gecko-based_Browsers" } ) }}</p>
Revert to this revision