Over a million developers have joined DZone.

How to Invoke a Web Service with Jaggery

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

Here's a snippet for invoking Jaggery, a framework to write webapps and HTTP-focused web services for all aspects of the application: front-end, communication, Server-side logic and persistence in pure Javascript.

var invokeRetrieveArtifactId =  function (applicationKey,version,revision){
    var ws = require('ws');
var retrieveArtifactIdProcess = new ws.WSRequest();
var options = new Array();
options.useSOAP = 1.1;
options.action = "urn:retrieveArtifactId";
options["HTTPHeaders"] = [ { name : "Cookie", value :modManager.getAdminCookie() }];
var payload = '<p:RetrieveArtifactIdRequest xmlns:p="http://retrieve.core.appfactory.carbon.wso2.org"><p:applicationId>'+applicationKey+'</p:applicationId><p:version>'+version+'</p:version><p:revision>'+revision+'</p:revision></p:RetrieveArtifactIdRequest>';
var result;

try {
   var endPoint =getProperty('ServerUrls.AppFactory')+'RetrieveArtifactService'; // provide the endpoint
   retrieveArtifactIdProcess.open(options,endPoint, false);
   result = retrieveArtifactIdProcess.responseE4X;
   var resultNS = new Namespace("http://retrieve.core.appfactory.carbon.wso2.org");
   var artifactDetails = result.resultNS::["return"].text()

       log.debug("Invoking service endpoint:"+endPoint+" returned result:"+result);
    return artifactDetails;
} catch (e) {
   log.error("Error while retrieving the artifact id"+applicationKey + "\n"+e.message);
   throw "Error while retrieving the artifact id"+applicationKey;

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Achala Chathuranga Aponso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}