Validate the Registration Using the Web Service
To validate a registration key using the service, create a new database with a standard module. Add the following VBA code to the module. We'll use the XMLHTTP object to send a GET request to the URL for the Web service.
We're using MSXML5, which is included with Office 2007.
Public Function IsValidRegistration(stRegKey As String) As Boolean Dim xmlhttp As Object Dim szUrl As String Dim stResponse As String Dim xmldom As Object
Create the XMLHTTP and DOMDocument objects as follows:
Set xmlhttp = CreateObject("MSXML2.XMLHTTP.5.0") Set xmldom = CreateObject("MSXML2.DOMDocument.5.0")
Specify the URL, which includes the call to the Web service. Notice that we're performing a GET request by specifying the parameters in the URL itself.
' set the URL szUrl = "http://<ServerName>/regws/registration.asmx/IsValidPIDKey?pidKey=" & stRegKey
Tell the XMLHTTP object to issue the GET request and send it to the server:
' get the XML from the web service xmlhttp.Open "GET", szUrl, False xmlhttp.send ' wait for a response While (xmlhttp.ReadyState <> 4) DoEvents Wend stResponse = xmlhttp.responseText
Because we are using an ASP.NET Web service, the response will come back as XML. Load this XML into a DOMDocument object using the loadXML method. We'll then parse this XML and look for the result of the IsValidPIDKey method defined in the service:
' parse the response If (Not (xmldom.loadXML(stResponse))) Then ' could not parse - return False IsValidRegistration = False Else IsValidRegistration = _ (xmldom.documentElement.childNodes(0).nodeValue = "true") End If End Function
To test the service, call the IsValidRegistration function in the Immediate window. Pass in a valid registration key twice. The function should return True the first time and False the second time when the PID table is updated.
If a Web service is not the appropriate mechanism for server validation in your architecture, there are many other methods you can use to validate a registration key. Other choices might include e-mail, telephone, key exchange using a text or XML file, or checking a file location for internal applications on a given network.
In this tutorial:
- Deployment
- Creating an Automated Build
- Design the Form
- Retrieving Information from the Source Database
- Building the Application
- Creating the Target Database
- Set Build Properties on the Target Database
- Setting Build Properties on the Source Database
- Deleting Data from Tables
- Calculating the Version Number
- Handling Application Dependencies
- Updating References
- Testing Reference Fix-Up
- Late Binding
- Licensing Your Applications
- Number of Records
- Restricting the Number of Times an Application is Launched
- Registering an Application
- Creating a Registration Web Service
- Validate the Registration Using the Web Service
- Miscellaneous Deployment Scenarios
- Create the Client Application
- Testing the Versioning Server
- Re-Linking Tables Automatically
- Programmatically Creating DSNs
- Creating a User DSN
- Ensuring an Application Runs Locally