Web Services, Part II: Calling Service Methods: Code Listing - Doc JavaScript | WebReference

Web Services, Part II: Calling Service Methods: Code Listing - Doc JavaScript


Web Services, Part II: Calling Service Methods

Code Listing

<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;
	webServiceCallerBody.useService(
	  "http://soap.bluestone.com:80/interop/EchoService/EchoService.wsdl","echo");
}
function callAsynch() {
	iCallID = webServiceCallerBody.echo.callService(
	  handleResult, "echoString", "Asynchronous Call");
}
function callSynch() {
	var co = webServiceCallerBody.createCallOptions();
	co.funcName = "echoString";
	co.async = false;
	var oResult = webServiceCallerBody.echo.callService(co, "Synchronous Call");
	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>

Next: A Final Word

http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 19, 2001
Revised: November 19, 2001

URL: http://www.webreference.com/js/column97/8.html