Web Services, Part II: Calling Service Methods
Attaching the WebService Behavior
In order to call remote methods from Web Services, you need to use the
WebService behavior. The WebService behavior is implemented as an HTML Component (
HTC), so it can be used in Microsoft Internet Explorer 5 and later versions. The
WebService behavior communicates with Web Services over HTTP using Simple Object Access Protocol (SOAP).
The first step in using the
WebService behavior is to attach it to an element using the
STYLE attribute. It is also necessary to set the
ID attribute so that this element can be easily referenced in script. You can attach the
WebService behavior to various types of elements. Here is an example that shows how to attach it to a
<DIV ID="webServiceCallerDiv" STYLE="behavior:url(webservice.htc)"></DIV>
And here is an example that shows how to attach it to a
<BODY ID="webServiceCallerBody" STYLE="behavior:url(webservice.htc)"></BODY>
The behavior can also be applied using other variations of Cascading Style Sheets (CSS) syntax.
To begin working with the
WebService behavior, download the
HTC file and copy it to the same directory as the Web page that uses the behavior. By placing the
WebService HTC file in the same directory as your HTML page that calls it, you avoid any DHTML behavior-related cross-domain security issues.
<PUBLIC:COMPONENT ID=_webservice Name="WEBSERVICE" > <PUBLIC:PROPERTY NAME="version" VALUE="Microsoft WebService Behavior 126.96.36.1990" /> <PUBLIC:PROPERTY NAME="showProgress" VALUE=false /> <PUBLIC:METHOD NAME="useService"/> <PUBLIC:METHOD NAME="createCallOptions"/> <PUBLIC:METHOD NAME="createUseOptions"/> <PUBLIC:METHOD NAME="invokeNext"/> <PUBLIC:METHOD NAME="callService"/> <PUBLIC:EVENT ID="eventResult" NAME="onresult"/> <PUBLIC:EVENT ID="eventService" NAME="onserviceavailable"/> </PUBLIC:COMPONENT>
Next: How to load a Web service URL