Google

Friday, August 10, 2007

Writing a simple Web service

Here is a procedure to write a sample web service. Please go through the steps given below.
Step 1:

The screen shot below shows the creation of new web service.




In the Web Services Properties box, give the new Web service a name -- we use TestService for this example -- and close the box.

Now you should have a screen that looks very much like one used for writing a LotusScript agent. Click (Declarations) in the Objects tab of LotusScript events, so you can write a class (classes must always be defined in the (Declarations) section). Enter this code into the IDE:


             
Class Test
Public Function AlertMsg (txt As String) As String
AlertMsg = txt
End Function
End Class
This code does the following:
  • Creates a class called Test.
  • Defines a method in the class called AlertMsg that accepts a string as a parameter and returns a string as a result (functions and subs in classes are referred to as methods).
This method accepts string as a input and returns the same string.

Open the Web Service Properties box and specify which class to use. Because there may be multiple classes defined in the Web service code, you must select only one of them as an interface to the Web service. The interface class is the one with Public methods that Web service clients can call.

In the Properties box, enter Test (the name of the class you just wrote) in the PortType class field on the first tab.


Here you have created a web service.

The further details working with complex functions, testing of web service, we will discuss in next posts.

No comments: