| AppliBuilder
User Documentation |
Your mashup applications can benefit from the growing pool of services and data available via web services. AppliBuilder provides a few simple tools to help you use REST-based Web Services from your script functions. SOAP support is not available at this time.
To make it easier to use web services,
a proxy service is
provided on the server to access remote web services. This is needed to
avoid cross-site scripting issues when accessing third-party web
services from your browser scripts.This proxy service can be used with
the URL <ROOT_CONTEXT>/xml/ajaxrestapi where <ROOT_CONTEXT>
is the AppliBuilder root path, for example /ajaxdc/xml/ajaxrestapi is
the URL for the proxy servlet. The Servlet supports the following
parameters:
Some library functions are provided to
simplify web services
development.
A few functions to access Web Services have been provided in core.js, a
library available in both the builder and runtime pages. Use the
Function Library item in Function menu to list and import functions.
var terms = getInputValue('Textbox4');
if (terms == '') {
alert("Please enter a search term");
return;
}
terms = encodeURIComponent(terms);The amzncallback argument is the function to be invoked when the service call returns, which is the next function we list below..
new Applibase.Core().xmlRESTService('http://webservices.amazon.com/onca/xml',
'Service=AWSECommerceService&AWSAccessKeyId=09518KE4JT7Y4GGJW882&Operation=ItemSearch&SearchIndex=Books&Keywords='
+terms, amzncallback);
var tbl = document.getElementById('AmazonTable');
if (tbl) document.body.removeChild(tbl);
var columns = new Array();
var x = xmlDoc.getElementsByTagName('Item');
var newEl = document.createElement('TABLE');
newEl.id='AmazonTable';
newEl.setAttribute('cellPadding',5);
var tmp = document.createElement('TBODY');
newEl.appendChild(tmp);
var row = document.createElement('TR');
for (j=0;j<x[0].childNodes.length;j++) {
if (x[0].childNodes[j].nodeType != 1) continue;
var nname = x[0].childNodes[j].nodeName;
if (nname == 'ItemAttributes') {
var anodes = x[0].childNodes[j].childNodes;
for (k=0;k<anodes.length;k++) {
var anode = anodes[k];
if (anode.nodeType != 1) continue;
if (columns.join('<>').indexOf(anode.nodeName) != -1)
continue;
var container = document.createElement('TH');
container.style.backgroundColor = "#d6f2d8";
var theData = document.createTextNode(anode.nodeName);
container.appendChild(theData);
row.appendChild(container);
columns.push(anode.nodeName);
}
} else {
if (columns.join('<>').indexOf(nname) != -1) continue;
var container = document.createElement('TH');
var theData = document.createTextNode(nname);
container.style.backgroundColor = "#d6f2d8";
container.appendChild(theData);
row.appendChild(container);
columns.push(nname);
}
}
tmp.appendChild(row);
for (i=0;i<x.length;i++) {
var row = document.createElement('TR');
for (var cj=0;cj<columns.length;cj++) {
var nname = columns[cj];
var ntext =
new Applibase.Core().getXMLColumnValue(x[i], columns[cj], ', ');
var container = document.createElement('TD');
container.style.backgroundColor = "#e7e7e7";
if (nname == 'DetailPageURL') {
ntext = '<a href=\"'+ntext+'\" target=\"_blank\" >Amazon Page</a>';
container.innerHTML = ntext;
} else {
var theData = document.createTextNode(ntext);
container.appendChild(theData);
}
row.appendChild(container);
}
tmp.appendChild(row);
}
document.body.appendChild(newEl);
| ©
2006 Applibase, Inc. |