Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Blogs

photo

Lotus Nut

69 Entries |  Chris Whisonant
Updated 
Ratings 4     Comments 96
photo

.Domino Frame...

86 Entries |  Peter Presnell
Updated 
Ratings 2     Comments 80
photo

Big A** Mutan...

42 Entries |  Michael Smelser
Updated 
Ratings 1     Comments 41
photo

TexasSwede

66 Entries |  Karl-Henry Martinsso...
Updated 
No Ratings 0     Comments 59
photo

B's Blog

29 Entries |  Bob Seifert
Updated 
No Ratings 0     Comments 22

Dogear Bookmarks

Yellow is the New Blog

Blog Authors:  Tim Tripcony  

All entries tagged with web_services

Consuming web services in Notes and Domino 8

Tim Tripcony  |     |  Tags:  web_services domino  |  Comments (0)
I haven't seen much discussion about how easy it really is to consume web services in Notes/Domino 8 (perhaps precisely because it is so easy), so I thought I'd outline exactly how one goes about providing and consuming services now.

Let's use a very basic example. Create a script library and toss this in the Declarations:

Public Class House
    Private currentColor As String
    Private currentValue As Long
    
    Public Sub buy (price As Long)
        Let Me.currentValue = price
    End Sub
    
    Public Function color() As String
        Let Me.color = Me.currentColor
    End Function
    
    Public Function value() As Long
        Let Me.value = Me.currentValue
    End Function
    
    Public Sub sell (price As Long)
        Let Me.currentValue = price
    End Sub
    
    Public Sub paint (newColor As String)
        Let Me.currentColor = newColor
    End Sub
End Class



Save that library, and create a web service. Include the library you just created via a Use statement in the Options, then in the properties of the service, specify House as the PortType class. The service doesn't need any code of its own, because it's aware of the House class via the Use statement and knows that's the class that defines the service methods.

Now it's time to consume the service. From within the service, click "Export WSDL", and save the file anywhere you can get to it later. In any Domino database (including, but not limited to, the database containing the web service), create a new script library (can be Java if you prefer, but in this example, we'll use LotusScript). At the bottom of the window you'll see a WSDL drop-down button. Click that and select "Import WSDL". It'll warn you that this will overwrite your script library (which is fine, since that's precisely what we want); click OK and select the file you just exported. Here's what you'll see:

%INCLUDE "lsxsd.lss"
Class House As PortTypeBase
    
    Sub NEW
        Call Service.Initialize ("UrnDefaultNamespaceHouseService", _
        "HouseService.Domino", "http://localhost", _
        "House")
        
    End Sub
    
    Sub BUY(PRICE As Long)
        Call Service.Invoke("BUY", PRICE)
    End Sub
    
    Function COLOR() As String
        Let COLOR = Service.Invoke("COLOR")
    End Function
    
    Function VALUE() As Long
        Let VALUE = Service.Invoke("VALUE")
    End Function
    
    Sub SELL(PRICE As Long)
        Call Service.Invoke("SELL", PRICE)
    End Sub
    
    Sub PAINT(NEWCOLOR As String)
        Call Service.Invoke("PAINT", NEWCOLOR)
    End Sub
    
End Class



Any of this seem familiar?

Only one change to the library is needed: replace the reference to "http://localhost" (in the Service.Initialize call) with "http://server/path/db.nsf/servicename?OpenWebService" (where server is the IP or DNS address of your Domino server, path/db.nsf is the full filepath of the database containing the service, and servicename is the name of the web service design element).

At this point, you can save the new library and include it anywhere you need to consume the service. And actually consuming it is this easy:

Dim myHouse As New House()
Call myHouse.buy(200000)
Call myHouse.paint("Purple")
Call myHouse.sell(5000000) 'Keep dreaming



But the real beauty of web services is that it allows you to execute functions against an application you know nothing about, whether it's inside your network or not. For example, if you download this file and import it into a script library in any of your applications, you can pull a random quote from my site as easy as this:

Dim Quotes As New Quotes()
Dim Quote As Quote
Set Quote = Quotes.getRandomQuote()
Msgbox Quote.Content & Chr(13) & "- " & Quote.Source




Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.