I needed to create a simple Lotus Notes Web Service. Since this is version 7 we are talking about it is a provider. The consumer comes in version 8 although there are very good ways to mimic the behaviour.
These tutorials on creating web services in Lotus Notes by Julian Robichaux are great:
-
-
-
As I wrote there are good ways of creating a web service consumer even in version 7. See by Joachim Dagerot for more on this. If you have version 8 it is even more .
Anyway, to the core of this blog entry. I created a simple web service by first writing a lotusscript class with a couple of simple methods in it. I set the adjustments on the web service to ‘RPC’ as programming model and ‘Doc/literal’ as SOAP message format, since ‘Doc/literal’ was what the consumer wanted for some reason:
Class test2 Private session As NotesSession Private db As NotesDatabase
Public Sub New () Set session = New NotesSession Set db = session.CurrentDatabase End Sub
Public Function PutAndGetModString (txt As String) As String PutAndGetString = txt + “_mod” End Function
Public Function GetDbName () As String GetDbName = db.Title End Function
Public Function GetTest () As String Bla = “Response string” End Function
End Class |
I exported the WSDL-file by pressing the button ‘Export WSDL’. In (an extraordinary free application to test web services by the way) I created a project and imported this WSDL-file. Requests to try out are created by default. Double-click on one to open a new window and run it to send the request and receive the response. I had some initial problems that the address to connect to (specified in the wsdl-file) was set to localhost. This is easily fixed by editing the url in the request window. The address should be the web-address to the webservice, i.e. ‘http://domainname/aFolder/database/webServiceName?WSDL’.
Using this the SOAP-request looks like this:
<soapenv:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:urn=”urn:DefaultNamespace”> <soapenv:Header/> <soapenv:Body> </soapenv:Body> </soapenv:Envelope> |
This brings the problem that calling the method GetDbName or GetTest returns the same response, i.e. from the GetDbName method. The reason for this is that the method is not defined in the SOAP-request and therefore the first one is chosen.
What I did that made it work was simply to replace ‘Doc/literal’ as the SOAP message format to ‘RPC/encoded’. Maybe someone knows how to adjust something so that the correct WSDL-file is created from Lotus Notes when using ‘Doc/literal’ for this to work.
Exporting the WSDL-file with this setting makes the SOAP-request look like this instead. You can see that the method name is specificed in the body.:
<soapenv:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:urn=”urn:DefaultNamespace”> <soapenv:Header/> <soapenv:Body> <urn:GETDBNAME soapenv:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”/> </soapenv:Body> </soapenv:Envelope> |
See how the web service is represented in SoapUI with all the methods.

And how the request window looks like for a method.

Finally here is the code for a lotusscript class with methods to return some statistics about a database. Download the WSDL-file or generate it yourselves if you’d like:
Class DatabaseStats Private session As NotesSession Private db As NotesDatabase Private nc As NotesNoteCollection
Public Sub New () Set session = New NotesSession Set db = session.CurrentDatabase’ End Sub
‘ Return database name Public Function GetDbName () As String GetDbName = db.Title End Function
‘ Return server name Public Function GetServerName () As String GetServerName = db.Server End Function
‘ Returns number of documents in the database Public Function GetNumDocuments () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectDocuments = True Call nc.BuildCollection GetNumDocuments = Cstr(nc.Count) End Function
‘ Returns number of forms in the database Public Function GetNumForms () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectForms = True Call nc.BuildCollection GetNumForms = nc.Count End Function
‘ Returns number of views in the database Public Function GetNumViews () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectViews = True Call nc.BuildCollection GetNumViews = nc.Count End Function
‘ Returns number of agents in the database Public Function GetNumAgents () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectAgents = True Call nc.BuildCollection GetNumAgents = nc.Count End Function
‘ Returns number of shared fields in the database Public Function GetNumSharedFields () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectSharedFields = True Call nc.BuildCollection GetNumSharedFields = nc.Count End Function
‘ Returns number of pages in the database Public Function GetNumPages () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectPages = True Call nc.BuildCollection GetNumPages = nc.Count End Function
‘ Returns number of outlines in the database Public Function GetNumOutlines () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectOutlines = True Call nc.BuildCollection GetNumOutlines = nc.Count End Function
‘ Returns number of actions in the database Public Function GetNumActions () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectActions = True Call nc.BuildCollection GetNumActions = nc.Count End Function
‘ Returns number of folders in the database Public Function GetNumFolders () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectFolders = True Call nc.BuildCollection GetNumFolders = nc.Count End Function
‘ Returns number of script libraries in the database Public Function GetNumScriptLibraries () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectScriptLibraries = True Call nc.BuildCollection GetNumScriptLibraries = nc.Count End Function
‘ Returns number of profile documents in the database Public Function GetNumProfileDocuments () As Integer Set nc = db.CreateNoteCollection(False) nc.SelectProfiles = True Call nc.BuildCollection GetNumProfileDocuments = nc.Count End Function
End Class |
Tagged as:
provider,
soap,
soapui,
web service