Pages

Wednesday, December 23, 2009

Creating and Consuming Web Service providers in Lotus Notes



Creating WebService
The following is a simple practical example, illustating how to create a simple web service and use the same.

Technologies Used: Lotus Script, Web Service Providers-Lotus Notes 8.5

1. Create a new WebServiceProvider design element

2. Give it a name : SimpleWebServiceProvider

3. Put the following into the Options section

Option Public
Option Declare
%INCLUDE "lsxsd.lss"

4. In the Declarations section add the following code

Class SimpleWebServiceProvider

Function echo(test As String)
echo= test
End Function

End Class

5.Ensure that the properties section of the web service is similar to the following

6. Save and close the web service

To ensure your webservice is working fine, open your browser and type in the following url as applicable to you,
"http: //servername/databasepath/SimpleWebServiceProvider?wsdl"

If you get a page with wsdl loaded then your webservice is working fine.

If your application is in your local hard disk and not in a server, then you may have to do the following work around to start the nhttp task for your local notes client.
1. Add a name, named "Anonymous" to the ACL and specify the same as person and manager
2. Open up a form in the Database and preview the same in IE and ensure that the form gets opened in the browser.

Once the above step is successful, type in the webservice url and preview it. Now it should run.


Consuming WebService

1. Open a database
2. Add a new form to it or open up an existing form
3. Add a new button to it
4. Put the following code into that button

Dim Client As Variant 'declares a variant
Set Client = CreateObject("MSSOAP.SoapClient") ' creats a soap client object
Call Client.MSSoapInit("http: //servername/databasepath/SimpleWebServiceProvider?wsdl")
Msgbox Client.echo("Yeppiee my webservice worked") ' calls a function defined in the web service


5. Preview the form in Notes Client
6. Click the button and view the Results :)

No comments:

Post a Comment