JavaScript DHTML/SmartClient/Web Services — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 10:00, 26 мая 2010

DynamicForm: call web services

 
<!--
Isomorphic SmartClient
Copyright(c) 1998 and beyond Isomorphic Software, Inc.
"SmartClient" is a trademark of Isomorphic Software, Inc.
All rights reserved.
Open Source License
SmartClient source code, located under the source/ directory, and the resulting assembled modules 
in isomorphic/system/modules/, as well as JavaScript and CSS files under the isomorphic/skins directory are 
licensed under the terms of the GNU Lesser General Public License, version 3. 
The text of the LGPLv3 license is available online at http://www.gnu.org/licenses/lgpl-3.0.html
If your project precludes the use of this license, or if you"d like to support SmartClient LGPL, 
we encourage you to buy a commercial license.
Icon Experience Collection
Selected 16x16 icons within the isomorphic/skins directory are part of the Icon Experience collection 
(http://www.iconexperience.ru) and may be freely used with any SmartClient components without charge, 
but may not be used as part of screen designs separate from SmartClient components without a purchase 
of a license from Icon Experience. We are working to replace these icons as soon as possible.
All other media found under the isomorphic/skins directory may be used under the LGPLv3.
Commercial Licenses
A number of commercial licenses are available for purchase. Please see http://smartclient.ru/license.
Warranty Disclaimer
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
Public License for more details.
Copyright 2001 and beyond Isomorphic Software, Inc. Last revised July 20, 2008. 

-->
<!-- The following code is revised from SmartClient demo code(SmartClient_70rc2_LGPL.zip).-->

<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>
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=5 BORDER=0><TR><TD CLASS=pageHeader BGCOLOR=WHITE>
  Web Service Operation Invocation
</TD></TR></TABLE><TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0><TR>
<TD BGCOLOR=336666><IMG SRC=images/blank.gif WIDTH=1 HEIGHT=4></TD></TR></TABLE>

<!--------------------------
  Example code starts here
---------------------------->
<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>



Web services data binding

 
<!--
Isomorphic SmartClient
Copyright(c) 1998 and beyond Isomorphic Software, Inc.
"SmartClient" is a trademark of Isomorphic Software, Inc.
All rights reserved.
Open Source License
SmartClient source code, located under the source/ directory, and the resulting assembled modules 
in isomorphic/system/modules/, as well as JavaScript and CSS files under the isomorphic/skins directory are 
licensed under the terms of the GNU Lesser General Public License, version 3. 
The text of the LGPLv3 license is available online at http://www.gnu.org/licenses/lgpl-3.0.html
If your project precludes the use of this license, or if you"d like to support SmartClient LGPL, 
we encourage you to buy a commercial license.
Icon Experience Collection
Selected 16x16 icons within the isomorphic/skins directory are part of the Icon Experience collection 
(http://www.iconexperience.ru) and may be freely used with any SmartClient components without charge, 
but may not be used as part of screen designs separate from SmartClient components without a purchase 
of a license from Icon Experience. We are working to replace these icons as soon as possible.
All other media found under the isomorphic/skins directory may be used under the LGPLv3.
Commercial Licenses
A number of commercial licenses are available for purchase. Please see http://smartclient.ru/license.
Warranty Disclaimer
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
Public License for more details.
Copyright 2001 and beyond Isomorphic Software, Inc. Last revised July 20, 2008. 

-->
<!-- The following code is revised from SmartClient demo code(SmartClient_70rc2_LGPL.zip).-->

<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>
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=5 BORDER=0><TR><TD CLASS=pageHeader BGCOLOR=WHITE>
  Web Service Binding Example (Google Search)
</TD></TR></TABLE><TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0><TR>
<TD BGCOLOR=336666><IMG SRC=images/blank.gif WIDTH=1 HEIGHT=4></TD></TR></TABLE>

<!--------------------------
  Example code starts here
---------------------------->
<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>