spacer
Yehuda Shiran December 7, 2001
Calling the EchoIntegerArray Web Service
Tips: December 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use

You can use the echoIntegerArray method to echo an integer array. Place the array elements inside a pair of square brackets, delimited by commas:

iCallID = webServiceCallerBody.echo.callService(
  handleResult, "echoIntegerArray", [1,5,11]);
Learn more about Web services in Column 96 (Web services, Part I: Introduction) and Column 97 (Web Services, Part II: Calling Service Methods).

Here is an HTML file that demonstrates calling a Web service. Copy it to your local disk, together with the WebService behavior (webservice.htc):

<HTML>
<BODY ID="webServiceCallerBody" onload="loadService()" 
  STYLE="behavior:url(webservice.htc);background-color:peachpuff;color:brown;font-size:18">
<SCRIPT LANGUAGE="JavaScript">
<!--
function loadService() {
	webServiceCallerBody.onserviceavailable = enableServiceCall;  //Used for the synchronous call.
	webServiceCallerBody.useService(
	  "http://soap.bluestone.com:80/interop/EchoService/EchoService.wsdl","echo");
}
function callAsynch() {
	iCallID = webServiceCallerBody.echo.callService(
	  handleResult, "echoIntegerArray", [1,5,11]);
}
function callSynch() {
	var co = webServiceCallerBody.createCallOptions();
	co.funcName = "echoIntegerArray";
	co.async = false;
	var oResult = webServiceCallerBody.echo.callService(co, [1,5,11]);
	handleResult(oResult);
}

function enableServiceCall() {
	b2.disabled = false;
}

function handleResult(res) {
  if (!res.error) {
    alert("Successful call. Result is " + res.value);
  }
  else {
    alert("Unsuccessful call. Error is " + res.errorDetail.string);
  }
}
// -->
</SCRIPT>
<HR><H4>Calls to an echo service</H4><HR><BR><BR>

<BUTTON ID="b1" onclick="callAsynch()">Call Asynchronously</BUTTON><BR><BR>
<BUTTON ID="b2" onclick="callSynch()" disabled>Call Synchronously</BUTTON><BR><BR><BR><BR>

<A HREF="http://www.xmethods.net/ilab/">Interop Testing Site</A>

</BODY>
</HTML>

People who read this tip also read these tips:

Look for similar tips by subject:

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags