Dashboard > Non-Metrix Tech Tips > ... > APIs > How to Create a Microsoft Access Client for a SOAP-based Web Service API
Non-Metrix Tech Tips Log In   View a printable version of the current page.
How to Create a Microsoft Access Client for a SOAP-based Web Service API
Added by A. Mitchell, last edited by A. Mitchell on Aug 01, 2006  (view change)
Labels: 
(None)

Introduction

Once you have created a SOAP-based API/web service, you can create a client to connect to that service. This document explains how to create a Microsoft Access client, but it is also possible to create a client in many other platforms, including any .NET technology, PHP, Perl, etc. Most of the code presented here can be easily adapted to work with other Microsoft Office products.

Note that the SOAP client used in Microsoft Office may not be able to handle complex SOAP services, so you may experience unexpected or inconsistent results in certain cases, even when .NET or PHP applications are able to interact with the SOAP service without any problems.

Requirements

  • A SOAP web service running on a web server.
  • Microsoft Access 2003
  • Microsoft Core XML Services (MSXML) 6.0 library (free download)

The example provided below assumes that the SOAP service:

  • is properly configured
  • returns results as string
  • has functions named GetAllContactNames and GetContactByID capable of returning a list of contacts and individual contacts, respectively

For information on creating such a web service, see How to Create a SOAP Web Service with Visual Studio .NET.

Getting Started

  1. Dowload and install the Web Services Toolkit for Microsoft Office 2003, v.2.01 or later. This is mandatory.
  2. Create a new Microsoft Access database.
  3. Enter the code window by create a new module in the database or using ctl-G.
  4. From the Tools menu, select "Web Service References".
  5. Select the "Web Service URL" option, and enter the URL of the WSDL file that defines the SOAP web service you want to access, e.g., http://example.com/metrixapi/metrix.asmx?WSDL. The toolkit will use the WSDL file to generate a class that you will be able to access directly in your VBA code. Note that the class and method names generated will not exactly match the methods described in the WSDL file. The web services toolkit add special prefixes to class and method names.

Accessing the Web Service

  1. Create a form.
  2. Add a text box named txtID, a text box named txtResults, and a button named cmdSearch.
  3. For the On Click event of cmdSearch, add this code:
    Private Sub cmdSearch_Click()
    Dim objClient As New clsws_metrix
    
    'assumes that SOAP service returns strings
    If If Nz(Me!txtID.Value) = 0 Then
        'show all contacts
        Me.txtResults.Value = objClient.wsm_GetAllContactNames
    Else
        'show only the contact specified
        Me.txtResults.Value = objClient.wsm_GetContactByID(Me.txtID.Value)
    End If
    
    End Sub
  4. View your form in Form View. Clicking the cmdSearch button should return a list of all contacts in the database. Entering a numerical value in txtID and clicking cmdSearch should return the name of the contact corresponding to that ID.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.1.1 Build:#406 Dec 23, 2005) - Bug/feature request - Contact Administrators