⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webservice2test.xml

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 XML
字号:
<?xml version="1.0"?><!--	This tests the BiWebService2 component--><Application xmlns:xhtml="http://www.w3.org/1999/xhtml">	<Window caption="Web Service Test"		width="750"		height="650">		><Label top="0" left="0" right="0" height="28"				backColor="white" foreColor="black"				padding="5" icon="../html/images/exclamation.16.png">			<Label.border>				<Border bottomWidth="2" bottomStyle="groove"/>			</Label.border>			This sample application tries to access another domain. This can be			allowed in Internet Explorer but not in Mozilla.		 </Label>	</Window>	<Resources>		<Package name="WebService2"/>		<Script><![CDATA[//////// Main Test Application Classfunction WebService2Test() {	var win = application.getWindow();	win.setOverflow("auto");	var lSamplesTab = new BiTabPane();	lSamplesTab.setLeft(5);	lSamplesTab.setTop(40);	lSamplesTab.setRight(5);	lSamplesTab.setBottom(5);	var lMathServiceTab = new BiTabPage("Math Service Test");	var lMathServiceTest = new MathServiceTest(lMathServiceTab);	lSamplesTab.add(lMathServiceTab);	var lGoogleTab = new BiTabPage("Google Test");	var lGoogleTest = new GoogleTest(lGoogleTab);	lSamplesTab.add(lGoogleTab);	win.add(lSamplesTab);}WebService2Test.main = function () {	new WebService2Test;};//////// MathService Test Classfunction MathServiceTest(aWin) {	var win = aWin;	// create the GUI components	this.inputField1 = new BiTextField("10");	this.inputField2 = new BiTextField("3");	this.resultField = new BiTextField;	this.operandButton = new BiButton("/");	this.resultButton = new BiButton("=");	this.statusBar = new BiStatusBar;	this.statusSection = new BiStatusBarPanel;	this.inputField1.setAlign("right");	this.inputField2.setAlign("right");	this.resultField.setAlign("right");	this.resultField.setReadOnly(true);	this.inputField1.setTabIndex(1);	this.operandButton.setTabIndex(2);	this.inputField2.setTabIndex(3);	this.resultButton.setTabIndex(4);	this.resultField.setTabIndex(5);	win.add(this.inputField1);	win.add(this.operandButton);	win.add(this.inputField2);	win.add(this.resultButton);	win.add(this.resultField);	this.statusBar.add(this.statusSection);	win.add(this.statusBar);	this.statusSection.setLeft(0);	this.statusSection.setRight(0);	this.statusSection.setPadding(2, 1);	// do the layout	this.inputField1.setLocation(5, 7);	this.inputField1.setWidth(50);	this.operandButton.setLocation(this.inputField1.getLeft() + this.inputField1.getWidth() + 5, 5);	this.operandButton.setWidth(20);	this.inputField2.setLocation(this.operandButton.getLeft() + this.operandButton.getWidth() + 5, 7);	this.inputField2.setWidth(50);	this.resultButton.setLocation(this.inputField2.getLeft() + this.inputField2.getWidth() + 5, 5);	this.resultButton.setWidth(20);	this.resultField.setLocation(this.resultButton.getLeft() + this.resultButton.getWidth() + 5, 7);	this.resultField.setRight(5);	this.resultButton.addEventListener("action", this.getResult, this);	// Create a drop down menu for the operand button	var m  = new BiMenu;	var operands = ["+", "-", "*", "/"];	var tmp;	for (var i = 0; i < operands.length; i++) {		m.add( tmp = new BiMenuItem(operands[i]) );		tmp.addEventListener("action", function (e) {			this.operandButton.setText( e.getTarget().getText() );		}, this);	}	// asssign the menu as a context menu and also show the menu when clicking	// the button	this.operandButton.setContextMenu(m);	this.operandButton.addEventListener("action", function (e) {		m.setLocation(this.operandButton.getScreenLeft(), this.operandButton.getScreenTop() + this.operandButton.getHeight());		m.setVisible(true);	}, this);	try {		this.createWebService();	}	catch ( ex )	{		alert( ex.message || ex.description || ex );		this.resultButton.setEnabled( false );	}}// WSDL URIs must be absolute//MathServiceTest.WSDL_URI = String( new BiUri( application.getAdfPath(), "../../services/MathService.asmx?WSDL" ) );MathServiceTest.WSDL_URI = "http://bindows.net/services/MathService.asmx?WSDL";MathServiceTest.prototype.createWebService = function () {	this.webService = new BiWebService2();        this.webService.setAsync(false);        this._wsReady = false;	// Load web service asynchronously	this.statusSection.setText("Looking up WSDL");        this.webService.addEventListener("serviceloaded", this.onServiceAvailable, this);        this.webService.useService(MathServiceTest.WSDL_URI, "[http://bindows.net/services/]MathService", false);};MathServiceTest.prototype.onServiceAvailable = function (e) {	// once ready we can initialize the service	if ( ! ("err" in e  ) )        {		this.statusSection.setText("Done");                this._wsReady = true;        }	else		this.statusSection.setText("Failed to initialize web service: " + e.err.toString());};MathServiceTest.prototype.getResult = function () {	// find the name of the function to call	var sFunctionName;	switch (this.operandButton.getText()) {		case "+":			sFunctionName = "add";			break;		case "-":			sFunctionName = "sub";			break;		case "*":			sFunctionName = "mul";			break;		case "/":			sFunctionName = "div";			break;	}	if ( this._wsReady ) {		this.statusSection.setText("Calling " + sFunctionName + "...");                try                {                   // call the service using this name                   var lRes = this.webService.callMethod(sFunctionName, { x: Number(this.inputField1.getText()),	                                                    y: Number(this.inputField2.getText()) });                   // MathService encapsulates returns in a single-member struct, whose member contains the result.                   // Return it.                   for(lN in lRes)                   {                      lRes = lRes[lN];                        break;                   }		   if (lRes == "INF")			lRes = Infinity;                   this.resultField.setText(lRes);                   this.statusSection.setText("Done");                } catch(e)                {                   this.statusSection.setText("Done but with errors");		   alert("Got an error\n\n" + e.toString());                }	}	else {		this.statusSection.setText("Web service is not ready");		alert("Web service is not ready");	}};//////// Google Test Classfunction GoogleTest(aWin){	var lLabel = new BiLabel("Google API key:");	lLabel.setLeft(10); lLabel.setTop(15);	aWin.add(lLabel);	this._keyInputField = new BiTextField("yUfzByFQFHIxUp9WLSJ3xcgq/riOrvqp");	this._keyInputField.setLeft(120); this._keyInputField.setTop(10);	this._keyInputField.setRight(10);	aWin.add(this._keyInputField);	lLabel = new BiLabel();	lLabel.setHtml("<b>Notice:</b> the default key supplied with this sample was obtained from Google for non-commercial use only. You can get your own key <a href=\"https://www.google.com/accounts/NewAccount?continue=http://api.google.com/createkey\" target=\"_blank\">here</a> and input it in the field above.");	lLabel.setLeft(120); lLabel.setTop(34);	lLabel.setRight(10);	lLabel.setWrap(true);	aWin.add(lLabel);	lLabel = new BiLabel("Search for:");	lLabel.setLeft(10); lLabel.setTop(85);	aWin.add(lLabel);	this._qInputField = new BiTextField("bindows");	this._qInputField.setLeft(120); this._qInputField.setTop(80);	this._qInputField.setRight(10);	aWin.add(this._qInputField);	this._searchBtn = new BiButton("Search");	this._searchBtn.setTop(110); this._searchBtn.setRight(10);	this._searchBtn.setEnabled(false);	this._searchBtn.addEventListener("action", this._onSearch, this);	aWin.add(this._searchBtn);	lLabel = new BiLabel("Search results:");	lLabel.setLeft(10);	lLabel.setTop(150);	aWin.add(lLabel);	this._statusBarWaitIndicator = new BiUndeterminedProgressBar();	this._statusBarWaitIndicator.setWidth(100);	this._statusBarWaitIndicator.setRight(10);	this._statusBarWaitIndicator.setTop(150);	this._statusBarWaitIndicator.setHeight(15);	this._statusBarWaitIndicator.setBackColor("transparent");	this._statusBarWaitIndicator.setVisible(false);	this._statusBarWaitIndicator.start();	aWin.add(this._statusBarWaitIndicator);	this._resultsGrid = new BiGrid2([["", "", ""]], ["Summary", "URL", "Size"]);	this._resultsGrid.setTop(165);	this._resultsGrid.setLeft(10);	this._resultsGrid.setRight(10);	this._resultsGrid.setBottom(10);	this._resultsGrid.setVisible(false);	aWin.add(this._resultsGrid);	this._resultsGrid.addEventListener( "dblclick", this._onGridActivate, this );	this._resultsGrid.addEventListener( "keypress", this._onGridActivate, this );	this._googleWs = new BiWebService2();	this._googleWs.addEventListener("serviceloaded", this._onServiceLoaded, this);	this._googleWs.addEventListener("callcomplete", this._onCallComplete, this);	try	{		this._googleWs.useService("http://api.google.com/GoogleSearch.wsdl", "[urn:GoogleSearch]GoogleSearchService", true);	}	catch ( ex )	{		alert( ex.message || ex.description || ex );		this._searchBtn.setEnabled( false );	}}GoogleTest.prototype = new Object();GoogleTest.prototype._onSearch = function(aEvt){  this._statusBarWaitIndicator.setVisible(true);  this._resultsGrid.setVisible(false);  this._googleWs.asyncInvoke("doGoogleSearch", this._keyInputField.getText(),        this._qInputField.getText(), 1, 10, true, "", true, "", "", "");}GoogleTest.prototype._onGridActivate = function( e ){   if ( e.getType() == "keypress" )   {      if (e.getKeyCode() != BiKeyboardEvent.ENTER )         return;   }   var sm = this._resultsGrid.getSelectionModel();   // don't bother about multiple selection here   var item = sm.getSelectedItems()[0];   if ( item )   {      var row = item.getRow();      window.open( this._resultsGrid.getRows()[row].getData( 1 ) );   }};GoogleTest.prototype._onServiceLoaded = function(aEvt){	// once ready we can initialize the service	if ( ! ("err" in aEvt  ) )	{		this._searchBtn.setEnabled(true);	}	else		alert("Failed to initialize Google web service: " + aEvt.err.toString());}GoogleTest.prototype._onCallComplete = function(aEvt){	if(!aEvt.getError())	{		var lRes = aEvt.getResult();		this._resultsGrid.removeAll();		this._resultsGrid.setColumnCount(3);		this._resultsGrid.setColumnNames(["Summary", "URL", "Size"]);		this._resultsGrid.setColumnWidths([300, 250, 50]);		for(var lResIdx=0; lResIdx<lRes.resultElements.length; lResIdx++)		{			var lSum = lRes.resultElements[lResIdx].summary;	 if(!lSum)		 lSum = lRes.resultElements[lResIdx].title;	 if(!lSum)		 lSum = lRes.resultElements[lResIdx].snippet;			this._resultsGrid.addRow(new BiGrid2Row([lSum, lRes.resultElements[lResIdx].URL, lRes.resultElements[lResIdx].cachedSize]));		}		this._resultsGrid.updateContentSize();		this._resultsGrid.update();		this._resultsGrid.setVisible(true);		this._statusBarWaitIndicator.setVisible(false);	} else	{		alert("Search error: " + aEvt.getErrorObject().toString());	}}	]]></Script></Resources></Application>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -