Skip to end of metadata
Go to start of metadata

This gadget allows a gadget author to invoke a SOAP Web Service, without cross-domain restrictions from the gadget's JavaScript. The SOAP Web service needs to be started before deploying such a gadget in the Gadget Server.

A SOAPRequest gadget code snippet is given below.

<?xml version="1.0" encoding="UTF-8" ?>  
     <ModulePrefs title="hello world example">  
     <Require feature="wso2.soap"/>
     <Content type="html">  
     <div id=response-disp></div>
      function doSOAPCall(){
       var endpoint = "http://localhost:9763/services/HelloService";
       var payload = ' <p:greet xmlns:p=""> <name>SOAP Request </name> </p:greet>';
       var operation = "urn:greet";
       document.getElementById("response-disp").innerHTML =, operation, payload);

Notable Syntax in the Code

  • Gadgets are specified in XML. The first line is the standard way to start an XML file. This must be the first line in the file.
  • The <Module> tag indicates that this XML file contains a gadget.
  • The <ModulePrefs> tag contains information about the gadget such as its title, description, author, and other optional features.
  • The <Require feature="wso2.soap"/> is used to inform the gadget container that this gadget needs an extra feature to invoke function. This type of features are pre-written Javascript code, which is loaded to the gadget on demand by the gadget container. In this code, it is required to import the feature 'wso2.soap', inorder to make a SOAP request from the gadget.
  • The line <Content type="html"> indicates that the gadget's content type is HTML.
  • <![CDATA[ ...insert HTML here... ]]> is used to enclose HTML when a gadget's content type is html. It tells the gadget parser that the text within the CDATA section should not be treated as XML. The CDATA section typically contains HTML and JavaScript.
  • JavaScript 'doSOAPCall' function defines three parameters required to invoke makeSOAPRequest function such as endpoint (Url of SOAP service ), payload and operation. Then by using ", operation, payload)" method, the SOAP service end point is invoked. Finally the response from the invoked SOAP service end point is displayed inside the gadget.
  • </Content> signifies the end of the Content section.
  • </Module> signifies the end of the gadget definition.
  • No labels