Writing a Hello World Client
The Mashup Server supports the quick and easy creation of Web services clients written in HTML and JavaScript. You can use the javascript stubs(?stub) generated by the Mashup Server to invoke the mashup services from your web page.
Mashup server also has the concept of bundling a custom UI along with the service. Follow these simple steps to write & expose a simple client for the helloworld service:
Step 1:
In Notepad or your favorite html editor, type the following text:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World Client</title>
<script type="text/javascript" src="/js/wso2/WSRequest.js"></script>
<script type="text/javascript" src="../helloworld?stub"></script>
</head>
<body>
<p>
<script>
<!-- set the address to match the scheme of the page address -->
helloworld.setAddress(helloworld.endpoint, "/services/helloworld");
<!-- use the generated stub to call the mashup service -->
var response = helloworld.hello("<test/>");
<!-- write the response by converting to a string (browser-independent) -->
document.write(WSRequest.util._serializeToString(response));
</script>
</p>
</body>
</html>
Step 2:
Save the above as "index.html" in the directory "scripts/helloworld.resources/www" within the Mashup Server directory. Now you'll be able to see the newly created page when browse to the service endpoint (eg: http://localhost:7762/services/helloworld).
You can also host this page independently of the mashup server by using the absolute path to the imported scripts as follows.
<script type="text/javascript" src="http://yourip:7762/js/wso2/WSRequest.js"></script>
<script type="text/javascript" src="http://yourip:7762/services/helloworld?stub"></script>