The service securedService running up on mooshup.com has been secured such that the request sent to this service should be encrypted and all requests should contain the username and password in a SOAP header (requires Username Token). Hence all registered user on mooshup can access this service. A client for this scenario would be simple as,
invokeSecuredService.inputTypes={"firstParam" : "string" , "secondParam" : "string"};
invokeSecuredService.outputType="string";
function invokeSecuredService(firstParam, secondParam) {
var request = new WSRequest();
var options = new Array();
options.encryptionUser = "keithspublickey";
options.username = "yourUsername";
options.password = "yourPassword";
var payload = {firstParam}{secondParam};
var result;
try {
var service = new QName("http://services.mashup.wso2.org/securedService", "securedService");
request.openWSDL("http://mooshup.com/services/keith/securedService?wsdl", false, options, service, "SOAP12Endpoint");
request.send("demo", payload);
var response = request.responseE4X;
result = response["return"].toString();
} catch (e) {
system.log(e.toString(),"error");
return result = e.toString();
}
return result;
}
You could follow the "Invoking Web Services from a Mashup" tutorial to get a feel of how easy it is to access web services using the WSO2 Mashup Server.
No comments:
Post a Comment