JavaScript DHTML/SmartClient/Web Services
DynamicForm: call web services
<source lang="html4strict">
<HTML><HEAD>
<SCRIPT>var isomorphicDir="isomorphic/";</SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT> <SCRIPT SRC=isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
</HEAD><BODY BGCOLOR="#e0e0e0" MARGINHEIGHT=0 MARGINWIDTH=0 LEFTMARGIN=0 TOPMARGIN=0>
Web Service Operation Invocation |
<IMG SRC=images/blank.gif WIDTH=1 HEIGHT=4> |
<SCRIPT>
// form to take user input of zipcode, and display city returned from web service
isc.DynamicForm.create({
ID:"zipForm", left:50, top:50, numCols:3, cellSpacing:5, items:[ {name:"ZipCode"}, {type:"button", startRow:false, title:"Find City", click:"zipForm.callService()"}, {name:"City", type:"staticText"} ], autoDraw:false, wsdlLoaded : function (service) { this.zipCodeService = service; this.show(); isc.clearPrompt(); }, callService : function () { isc.showPrompt("Looking up city code..."); this.zipCodeService.callOperation( "GetInfoByZIP", // operation name {USZip:zipForm.getValue("ZipCode")}, // inbound data for operation "//CITY", // XPath, Type, or ElementName to extract result "zipForm.setValue("City", data[0]);isc.clearPrompt()" // script to execute when operation returns ); }
}); var wsdlURL = "http://www.webservicex.net/uszip.asmx?WSDL"; isc.showPrompt("Loading WSDL from: " + wsdlURL); isc.XMLTools.loadWSDL(wsdlURL, "zipForm.wsdlLoaded(service)");
</SCRIPT> </BODY> </HTML>
</source>
Web services data binding
<source lang="html4strict">
<HTML><HEAD>
<SCRIPT>var isomorphicDir="isomorphic/";</SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT> <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT> <SCRIPT SRC=isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
</HEAD><BODY BGCOLOR="#e0e0e0" MARGINHEIGHT=0 MARGINWIDTH=0 LEFTMARGIN=0 TOPMARGIN=0>
Web Service Binding Example (Google Search) |
<IMG SRC=images/blank.gif WIDTH=1 HEIGHT=4> |
<SCRIPT>
var wsdlURL = "http://api.google.ru/GoogleSearch.wsdl";
isc.showPrompt("Loading WSDL from: " + wsdlURL);
isc.XMLTools.loadWSDL(wsdlURL, "wsdlLoaded()");
function wsdlLoaded() {
window.service = isc.WebService.get("urn:GoogleSearch"); if (service == null) isc.warn("WSDL not currently available from Google (tried "+wsdlURL+")"); window.inputsDS = service.getInputDS("doGoogleSearch"); window.resultsDS = service.getFetchDS("doGoogleSearch", "ResultElement"); isc.VLayout.create({ height:"90%", width:"100%", top:40, membersMargin:20, layoutMargin:40, members:[ isc.SearchForm.create({ ID:"searchForm", numCols:4, width:500, dataSource:"inputsDS", values:{ key:"/90Hfy0p5FxaC8YOxKoQKFFFfeKUjJWp", q:"[enter search here]", start:"0", maxResults:"10" } }), isc.Button.create({ click:"searchResults.fetchData(searchForm.getValuesAsCriteria())", title:"Search" }), isc.ListGrid.create({ ID:"searchResults", dataSource:"resultsDS" }) ] }); isc.clearPrompt();
} </SCRIPT> </BODY> </HTML>
</source>