Web Service is very useful method for the interaction with other machines over network.To leverage web services in Domino, a New feature called Web Service is added in R7 onwards. From R8 onwards this feature is further divided into two sections "Web Service Providers" and "Web Service Consumers". With both the options, you can create web service which can be read by other platform and vice versa. Domino can consume web services written on other platform.
In this post , I will create a web service using Domino 8.5 and will read that web service in my Eclipse application. Let's begin with the example.
I've a Lotus Notes application which keeps airlines travel availability configurations. Let's say my form name is "CheckMyTravelDate" with five fields; Departure date,Return date,From country,To country and availability status.Here is my form ,
Next, Create a view which will be used for look-up in our web service code.It will have two columns; First column is with key "Start Date-End Date-From-To" and second column is "Availability Status". We need to make first column categorized. Shown below,
Let's begin with Web Service.
Since we're going to provide Web Service, so click "New web service provider" button under "Web Service providers" section.
You will have two options to write web service ; Lotus Script and Java. Choose "Lotus Script" (default). Paste following code in your web service ,
Option Public Option Declare %INCLUDE "lsxsd.lss" Class getTravelStatus Function getTravelStatusString(StartDate As String, EndDate As String, Departure As String, Returns As String) As String Dim s As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim doc As NotesDocument Dim key As String Dim sd As New NotesDateTime(StartDate) Dim ed As New NotesDateTime(EndDate) Set db = s.CurrentDatabase If Not(db.IsOpen) Then getTravelStatusString = "Cannot open travel configuration database " Exit Function End If Set view = db.GetView("CheckMyTravelDate") If view Is Nothing Then getTravelStatusString = "Cannot open travel configuration view " Exit Function End If key = Cstr(sd.DateOnly)+"-"+Cstr(ed.DateOnly)+"-"+Departure+"-"+Returns Set doc = view.getDocumentByKey(key) If doc Is Nothing Then getTravelStatusString = "Sorry, Booking is not available with specified details" Exit Function Else getTravelStatusString=doc.GetItemValue("availabilityStatus")(0) End If End Function End Class |
What my code does :
It's pretty simple program implemented using class called getTravelStatus which has one function called getTravelStatusString.This function takes four arguments;Travel start date,end date,departure country and return country. It builds the key , pass to the view,get the availability status and returns to the calling function.
Now when we try to save web service, we will get following warning
Warning says, your class name should match with PortTypeClass.Open web service property window and paste your class name in PortTypeClass section.
Go to third tab of web service property window and select Programming model as RPC and SOAP message format as RPC/encoded.At the end specify other details like Port type name , service element name and Service port name which are optional parameters.Save your changes.
Now you've to run your web service on browser using ?WSDL ( http://server/database/getTravelStatus?WSDL ) command to verify everything is fine.If everything is fine, you get screen like,
You've successfully created web service, now time to test.
There are various method to test web service . I'm going to use Eclipse and the Web Tools Platform (WTP). To do so , first install Eclipse and then configure WTP in your machine.
Once installed and WTP configured is done, Open Eclipse and go to Run->Launch the Web service explorer. Click on "WSDL" page icon on top right top open WSDL window.
(or follow the same step mentioned here)
Click on "WSDL main" at left panel and provide your web service path at right panel and click on "Go".
You can check the status at lower panel whether your web service is successfully opened or not.Click on your web service name under "Operations" section.You can find the form to enter , Travel start date, end date,to country and from country . Enter data and click "Go",
So these were the basic steps to implement and test web services in Lotus Notes.
Write me for any suggestions/comments.
June 5, 2009 at 5:42 AM
Excellent tutorial. I would like to see the other side of the coin by showing how to consume the service
June 5, 2009 at 10:46 AM
@ Patpicos, To implement Web Service provider you don't need to learn writing WSDL file.Domino does for you.However for web service consumer you've to know. I'm doing some start up work in Apache Axis, If I get it done in Axis , sure will put new post on Web Service consumer.
June 8, 2009 at 5:52 AM
bhai.. as usueual nice input from you on one another nice topic which is pretty new to Lotus Notes itself as it was introcuced in version 7 only.
your step by step guidenece is more than usefull for the beginners like me.. I will be configuring the same.. and will ask you the querys as and when required...
Keep up the good work mate.. cheers
July 19, 2010 at 2:41 AM
Hi Rishi,
Thanks for detailed explanation on domino web service.
Regards
Ajay B Mali
August 25, 2010 at 2:17 PM
Has anyone tried building a Xcelsius dashboard to consume data from web services on Lotus Notes?
September 24, 2010 at 1:08 AM
Hi Rishi,
Thanks for the wonderful step by step details. It clears my doubts in case of web service providers. I am struggling to view web service explorer in eclipse at my end. I have done below steps to set up eclipse and WTP :
0. I am having windows - XP / SP3
1. Downloaded eclipse-jee-helios-win32.zip ( size 206mb ).
2. Extracted eclipse files to one of my folder C:\Rohit\Lotus-R8.5
3. Downloaded wtp-R-3.2.1-20100730021206.zip ( 80 mb ).
4. Extracted wtp files to same folder C:\Rohit\Lotus-R8.5. It prompted me to override some files I answered yes to those prompts, assuming it is updating them.
Then tried to look for web services explorer using run menu option in Eclipse but could not view the same.
Please help me if possible. Can you please give me your skype id so that I can give more details on this if you need
Many thanks
Regards,
Rohit
In case you wish to contact me for more detailsmy Skype id : uprohit
September 24, 2010 at 11:11 AM
Hi Rishi,
Eclipse problem is now resolved by re-intalling the eclipse under program files folder and by removing previously created workspace folder created by eclipse.
Thanks.
Cheers
Rohit
December 19, 2011 at 8:14 AM
Hi Rishi
I am new to web services and have followed your tutorial (very good by the way) but when it comes to test, I get this error,
IWAB0379E Unable to open http://localhost/dev/VisitorR.nsf/getTodaysVisitors?WSDL.
IWAB0135E An unexpected error has occurred.
WSDLException
WSDLException: faultCode=OTHER_ERROR: http://localhost/dev/VisitorR.nsf/getTodaysVisitors?WSDL
Any ideas what might be wrong, am I making a school boy error?
Cheers
December 27, 2011 at 6:50 AM
Hi Rishi,
Please help me on how to consume a web service [coding]. I am in a situation where i need to invoke couple of web service methods which interacts with DB2 database server and retrieves the data. Although i have consumed a web service successfully i am not clear about the concepts in coding. Here's the link what i followed
http://thinkgreat.blogspot.com/2007/03/web-service-consumer.html
December 27, 2011 at 6:55 AM
Hi Rishi, Here's the link which helped me consume web service. I was successful in consuming and retrieving the values. Although i am not clear about the concepts in coding.
http://thinkgreat.blogspot.com/2007/03/web-service-consumer.html
Great if you could help me.
April 23, 2012 at 11:22 PM
Hi Rishi,
First I would like to thank you for Excellent Post .
I need to get wheather Report from internet.
Thanks in Advance.