< Back

Document Subject: How to make a web service in Lotus Notes 8 in 10 mins
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#webservice or http://A555F9/nn.nsf/ByAlias/webservice

Here is a quick refresher on how to build and test a webservice and webservice consumer and a form to test this.




Here is the web services refresher:

Create a new database on the dev server.
Add anonymous and set type to unspecified and access to editor
Open in designer.
Expand Code
Right click on web Service Providers and select New Web Service Provider
Enter name “WS1”
Click on Declarations and enter this code:
Class WebServiceOne
 Sub NEW
 End Sub
 Function op1(input1 As String, input2 As String) As String
  op1=input1 & "---" & input2
 End Function
 Function op2(input1 As String, input2 As String) As String
  op2=input1 & input2
 End Function
End Class

Click on Properties (or do a Alt+Return)
Enter Port Type as “WebServiceOne” ie same as class name
Save Web Service.
You’ve created a webservice !!!
Click on Export WSDL and save the wsdl file somewhere handy.
Click on “Design->Preview in Web Browser->Default Browser”
Make a note of the full URL. Click on WSDL if you want.

Ok let’s consume the webservice.
In the designer, expand Code, and right click on Web Service Consumers.
Select New Web Service Consumer.
Enter WSC as the name.
Select the Local WSDL file as noted down earlier.
NB or use the WSDL url from the Preview in Browser for better results.
Change the Url http://localhost to the url of the webservice http://.../db.nsf/WS1
Save!
OK we’ve created a consumer.
Now create a form to use the web services consumer.
Create a new form.
In Global Options:
Option Public
Use "WSC"
Add fields fld1 , fld2, result, and result2
In a button put:


Dim s As New notessession
 Dim wws As New WebServiceOne
 
 Dim uiw As New notesuiworkspace
 Dim uidoc As notesuidocument
 Set uidoc= uiw.currentdocument
 
 Dim res As String
 res= wws.OP1(uidoc.FieldGetText("fld1"),uidoc.FieldGetText("fld2"))
 
 Call uidoc.FieldSetText("result", res)
 
 res= wws.OP2(uidoc.FieldGetText("fld1"),uidoc.FieldGetText("fld2"))
 Call uidoc.FieldSetText("result2", res)

Test by putting letters in fld1 and fld2 and pressing the button.