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 :
Note:The Mashup server should be running the helloworld service for this to work.
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="/services/helloworld?stub"></script>
</head>
<body>
<p>
<script>
<!-- use the generated stub to call the mashup service -->
var response = helloworld.hello();
<!-- write the response to the browser -->
document.write(response);
</script>
</p>
</body>
</html>
Step 2:
Save the above as "index.html" in the directory "repository/scripts/Helloworld.resources" within the Mashup Server directory. Now you'll be able to see the newly created page when browse to the service endpoint (eg: http://{ip-of-mashup-installation}:9763/services/helloworld). Thats it, its so simple.
Or, not simple enough for you? You can also get a template for a service, similar to the one above but customized to the service, by entering this url for your service. i.e. http://{ip-of-mashup-installation}:9763/services/helloworld?template&flavor=html and saving response as "index.html". This template invokes the first operation in the service asynchronously, and illustrates how to invoke all the other services as well.
Do you need even simpler method? Then you can go the mashup editor page and the tabs at the top will shift you among your service, custom UI and Google gadget. Why are you waiting! Start adding parameter values and build a unique and dynamic Mashup interface!