You are on page 1of 10

Not es/Domi no 8.

5 Wor k shop
Lab Manual

Lab 7
Usi ng Web Ser vi c es

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 1 of 10

I nt r oduc t i on:
The Web Service design element was introduced in Lotus Notes V7.0, which allowed you to create a Web
Service on a Lotus Domino server. This was a provider, a Web Service that could be called from other
computers. Lotus Notes 8.5 lets you create a Web Service Consumer that runs on a Lotus Domino server
and calls Web Services to obtain the data they serve up, and then inserts it into your Lotus Notes
application.
This Web Service Consumer is instantiated as a special kind of CODEDdesign element (LotusScript or
J ava). The content of this consumer is a Web Service Definition Language document, the description of
the Web Service in an XML format. The WSDL is imported into the consumer and compiled to a script
when it is saved. The [Declarations] section of the script calls the Web Service.
Desc r i pt i on:
In this lab, you will learn how to create a simple Web Service provider called LastContact that returns the
last contact date and contact name from your database. You will also learn how to create a Consumer
which serves as a web client library that you can call from other parts of your application. Later in the lab,
you will create a front end access point to this Web Service

Obj ec t i ve:
At the end of the lab, you should be able to:
Create a Web Service Provider
Create a Web Service consumer that consumes the service
Create an action for the user to call the Web Service


COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 2 of 10

Pr oc edur e:
SECTION 1: PREPARE THE DATABASE
In this section, you will Replicate the Call Tracking database to DOM85.
Step 1 Launch Lotus Notes, if it is not already running.
Step 2 Click the Open button then select Workspace.

Step 3 Locate and Right-click on Call Tracking on Local.

Step 4 Select Replication-> New Replica

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 3 of 10

Step 5 Change the server to DOM85/ibm, change the file name to Tracking.nsf, and click OK.

Step 6 Allow the server about 20 seconds to replicate the application then Close the Replication tab.


SECTION 2: CREATE A WEB SERVICES PROVIDER
In this section, you will create a simple Web Service provider called LastContact using LotusScript (you could just as
easily use Java to write your Web Service) that returns the name and date of the last registered contact. You will then
view the generated WSDL file and in the next sections you will generate a Web Services consumer that calls this Web
Service.
Step 1 Open Domino Designer.
Step 2 Click File >Application >Open then switch the Look in to DOM85/ibm, and Open the Call
Tracking application.

Step 3 In the Applications View, expand Code and double-click on Web Service Providers.

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 4 of 10

Step 4 Click New Web Service Provider.

Step 5 Enter the Name LastContact and click OK.
Step 6 Fill out the first and third tabs of the properties box as shown below.

Step 7 Ensure LotusScript is selected for the programming language, and enter the following code in
the Declaration section. This code can also be found at c:\Lab Files\C&P.doc.
%INCLUDE "lsxsd.lss"
Dim session As NotesSession 'global service variables
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As notesdocument
Dim vec As notesviewentrycollection
Dim ve As notesviewentry

Class LastContact

Sub NEW ' class constructor
Set session =New notessession
Set db =session.CurrentDatabase
End Sub

Function LastContacted As String
Set view =db.GetView("(calls by contact by date)")
Set vec =view.AllEntries
Set ve =vec.GetFirstEntry
Set doc =ve.Document
If Not doc Is Nothing Then

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 5 of 10

lastcontacted =doc.Contact(0) +" on " +Cstr(doc.date(0))
Else
lastcontacted ="No contacts"
End If
End Function
End Class


Step 8 Save and close the Web Provider.
Step 9 Open an internet browser and navigate to
http://notesdomino.dfw.ibm.com/Tracking.nsf/LastContact?WSDL.
Step 10 Ensure the website above shows an XML display of the Web Service.



COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 6 of 10

SECTION 3: CREATE A WEB SERVICES CONSUMER
In this section, you will create a simple Web Service consumer called LastCall using LotusScript, again you could just as
easily use Java to write your consumer. You will use a shortcut to ensure the formatting is all correct by using the URL
from the last step.
Step 1 Back in Domino Designer, click File >Application >Open and open Personal Contacts
from local.

Step 2 In the Applications View, expand Code and double-click on Web Service Consumers.
Step 3 Click New Web Service Consumer.
Step 4 Enter Last Call for the name of the new consumer.
Step 5 Select URL that points to a WSDL file and enter the URL
http://notesdomino.dfw.ibm.com/Tracking.nsf/LastContact?WSDL.

Step 6 Click OK.
Step 7 Save and Close the Web Service Consumer.

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 7 of 10

SECTION 4: CREATING AN ACTION USING THE WEB SERVICE CONSUMER
In this section, you will create a view action which uses the Web Service similar to how a Script Library is used. This
View action will show in your composite application.
Step 1 In the Applications View, expand Views and double-click on Name CO at the bottom of the
list.

Step 2 Right-click inside the Action Bar panel and select Create Action

Step 3 Name the new action Last Contact Made.


COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 8 of 10

Step 4 Change the programming language to LotusScript.

Step 5 Enter the code pictured below to the Options subroutine of the action. This will link the action
to the Web Consumer the same way we would expect it to link to a Script Library.

Step 6 Add the following code to the Click subroutine: This code can also be found at c:\Lab
Files\C&P.doc.
Dim myval As String
Dim ServiceObj As New LastContact 'name of the class defined as both the producer and consumer
myval = ServiceObj.LASTCONTACTED ' lastcontacted was a parameterless method of the producer
Messagebox " Last Call Tracking communication was made to " + myval + " ." , 64 , " Last Communication"



Step 7 Save and Close the view.

COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 9 of 10

Step 8 If Lotus Notes 8.5 is not already running, start it now.
Step 9 Click File >Open >Lotus Notes Application and open MyCompApp.nsf.

Step 10 Click on the recently created Last Contact Made button. You will now see the results of the
Web Service usage: A Remote Procedure Call is made to our one application from the other
using a URL as an access point which returns what the latest dated communication is.

Summar y:
Congratulations! You have completed this lab.
In this lab, you have learned how to create a simple Web Service provider called LastContact using LotusScript that
returns the latest dated communication from another database. You also learned how to create a Web Service consumer
from a WSDL URL. Later in the lab you created a front end access point to retrieve information using the Web Service
consumer.


COPYRIGHT IBM CORPORATION 2009. ALL RIGHTS RESERVED. IBM ISV & DEVELOPER RELATIONS.

Page 10 of 10

You might also like