The Kat's Work - Blog
Main | Blog | Registration | Login
Friday
2024-03-29
2:54 PM
Welcome Guest | RSS
Main » 2011 » March » 25

Much has been made of lotus notes xPages functionality, which is IBMs attempt to scrabble back ground on other web technologies. In my opinion its got a long way to go, before its usable never mind a contender. This push by notes though has meant that another addition to note’s functionality has been widely over looked. This is the ability for notes databases now to provide and consume web services.

Notes has always been jealous of its data, access to it from outside of notes was always a difficult task as was injection of data into it. With the adding of web services this hardship evaporates. Already through this method I have been able to make a Java Spring web application "talk” directly with notes and attached BIRT to allow proper reporting on notes data for the first time ever! I think this is just the tip of the iceberg, and yes its notes so it isn’t perfect yet there are some functions need improving but its an infinite improvement.

To create a notes web services you first need to create a class. This class will be associated with your web services. Functions of the class will become the services operations.


Dim session As NotesSession
Dim db As NotesDatabase

Class CustomersService
Sub New
        Set session = New NotesSession
        Set db = session.CurrentDatabase
    End Sub

    Function sayHello() as string

        SayHello = "Hello”

    End Function
   
End Class

This class will create operation sayHello for your web service. The operation will return a string.

We next need to create the web services provider. Located under the code section of the database in domino designer. In the properties of the provider, we need to set the following:

Port type class CustomerService (i.e the name of the Class)

Port Type Name CustomerService (for wsdl)

Service Element name CustomerService (for wsdl)

Port name Domino (for wsdl)

Your web service will now be available at http://<server>/<path>/<nsf>/<web service> and wsdl at http://<server>/<path>/<nsf>/<web service>?WSDL

More Complicated WebServices

So how do we set up more complicated operations. We can wrap the functions response with other classes. This allows us to return pretty much anything we want.

Class ReportStubs
    Public message As String
    Public reportStubs() As ReportStub
   
End Class

Class ReportStub
   
    Public reportPeriod As String
   
End Class

Dim session As NotesSession
Dim db As NotesDatabase

Class CustomersService
Sub New
        Set session = New NotesSession
        Set db = session.CurrentDatabase
    End Sub

    Function sayHello() as string

        SayHello = "Hello”

    End Function

Function getCustomersAvailableReports(userID As String, securityKey As String, userKey As String) As reportStubs
        Set getUsersAvailableReports = New ReportStubs
        If ( Not Me.checkSecurityKey(securityKey)) Then
           
            getUsersAvailableReports.message = "Access Denied"
            Exit Function
           
        End If
        Dim userConical As String
        userConical = Me.getUserConical(userID,userKey)
        If (userConical = "") Then
           
            getUsersAvailableReports.message = "User Invalid"
           
            Exit Function
           
        End If
        Dim view As NotesView
        Set view = db.GetView("Reports")
        Dim viewEntries As NotesViewEntryCollection
        Dim viewEntry As NotesViewEntry
       
        Set viewEntries = view.GetAllEntriesByKey(userConical ,False)
       
        Set viewEntry = viewEntries.GetFirstEntry
       
        Redim getUsersAvailableReports.reportStubs(0 To (viewEntries.Count-1))
       
        i% = 0
        While Not viewEntry Is Nothing
            Dim reportStub As New ReportStub
           
            reportStub.reportPeriod = viewentry.ColumnValues(1)
           
            Set             getUsersAvailableReports.reportStubs(i%) = reportStub
            i% = i% + 1
            Set viewEntry = viewEntries.GetNextEntry(viewEntry)
        Wend
       
        getUsersAvailableReports.message = "Success"
       
    End Function

Private Function getUserConical(userID As String, userKey As String) As String
       
        getUserConical =  "The Kat"
    '    getUserConical =  ""
    End Function
   
    Private Function checkSecurityKey(securityKey As String)
        If (securityKey = "") Then
           
        End If
        checkSecurityKey = True
       
    End Function
   
End Class

As you can see this will create a operation that will accept a message of there string parameters. The response will be a complex message type as specified by classes ReportStubs and ReportStub.

Views: 2640 | Added by: The_Kat | Date: 2011-03-25 | Comments (0)

Login form
Adverts
Search
Calendar
«  March 2011  »
SuMoTuWeThFrSa
  12345
6789101112
13141516171819
20212223242526
2728293031
Entries archive
Site friends
  • Create your own site
  • Spree4.com
  • My Blog
  • Statistics

    Total online: 1
    Guests: 1
    Users: 0
    spree4
    Copyright MyCorp © 2024
    Website builderuCoz