|[ Team LiB ]|
Recipe 17.4 Call a Web Service from Access
A web service is a specially constructed component that you can access over standard web protocols. To call a web service, however, you must pass it messages encoded using Simple Object Access Protocol (SOAP). Access does not directly support the SOAP protocol. Is there any way to call a web service from Access?
Microsoft has released several toolkits that can be used by Microsoft Office programmers to call web services. This solution assumes you are using Access 2003 with Microsoft Office 2003 Web Services Toolkit. See the discussion section of this topic on calling web services from earlier versions of Access.
The RunnerCalculator web service contains a number of methods that provide pacing calculations for long distance running. This web service can be found at www.deeptraining.com/webservices. One of the RunnerCalculator methods, GetPaceDouble, can be used to calculate the pace in minutes per mile for a given distance and total time. Follow these steps to create an Access 2003 form that uses this web service to calculate pace for a user-entered distance and time:
When you set a reference to a web service using the Microsoft Office 2003 Web Services Toolkit, the toolkit creates a proxy class with the name clsws_webservice, where webservice is the name of the web service. The proxy class takes care of calling the web service using SOAP and processing the response, again using the SOAP protocol.
For every method of a web service, the Microsoft Office 2003 Web Services Toolkit creates a corresponding method of the proxy class with the name wsm_method, where method is the name of the web service method. Thus, calling the web service is as simple as instantiating the proxy class and calling the proxy method corresponding to the method in the web service.
188.8.131.52 Calling web services from earlier versions of Access
If you wish to call a web service from Access XP or an earlier version of Access the solution steps will differ from those shown here. If you're using Access 2002, you need to download and install the Microsoft Office XP Web Services Toolkit 2.0. The steps to use the Office XP toolkit are fairly similar to using the Office 2003 toolkit. If you need to call a web service from Access 2000 or an earlier version of Access, you'll need to use the Microsoft SOAP Toolkit 3.0. This toolkit is geared more towards Visual Studio 6.0 developers, but can also be used from VBA code.
184.108.40.206 Locating the toolkits
The Microsoft Office 2003 Web Services Toolkit can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=fa36018a-e1cf-48a3-9b35-169d819ecf18&DisplayLang=en.
The Microsoft Office XP Web Services Toolkit 2.0 can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpwst2/html/odc_offxpwstoolkit2.asp.
The Microsoft SOAP Toolkit 3.0 can be found at http://msdn.microsoft.com/library/default.asp?URL=/downloads/list/websrv.asp.
17.4.4 See Also
Integrating XML Web Services Into Microsoft Office Solutions (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office09062001.asp).
|[ Team LiB ]|