Portalizing an IBM Lotus Domino view or form It has been reviewed by two experts Stephan wissel ( IBM Singapore) and Kiran Bellari ( ex- IBMer and Consulatant in Infosys India) Introduction: This article demonstrates how simply you can use Web services in the Lotus Domino development environment. It shows how you can extract a list of all Action button names from a Lotus Notes view or form. This ability gives you an edge when you want to portalize a Lotus Domino application. The major advantage here is we are using lotus script to create this webservice , this gives advantage to many domino developers who are well versed with lotus script ,to play with Webservice and can leverage their skills in creating webservice without much effort. here we make use of Standard classes of lotus script such as NotesDXLExporter,NotesXSLTransformer and NotesDOMParser ,. Etc Abstract: This article helps domino developers to understand how easily one can leverage the power of webservice with a simple example along with the code in lotus script .The basic idea of the article is to show how easily we can create a Web service in an IBM Lotus Domino database to pull out the names of Action buttons in design elements (forms/views) This is quite useful in leveraging domino capabilities to support webservice , especially in case of portalizing any domino application . This will enable the developer to pull out all action buttons of any design element (form/view ) of any database dynamically. In current situations many organizations have a Mixed environment with Lotus Domino and IBM websphere and It is very Important to have a portalization of their current existing complex notes applications This article shows how simple to create a webservice especially in the context of moving any domino application on to Portal server or for dual access (on domino as well as Portal server).Developers will understand the Power and importance of Webservice in the current World as Webservice is a Universal Interface between different technologies This article covers how to design a webservice including code and also tells about how to test it and see the output Designing a Webservice from Notes designer client: Softwares used: Websphere Portal Server 6.0, Domino 7.0.2 The following steps explain how to create a Web service and to request this Web service from WebSphere Portal. 1)open notes designer client and create a new database by choosing File-> databse New from Menu 2)Select the Sever and enter database title as “Portal configuration tool” and file name as “PortalConfig.nsf” and press OK button to create a new lotus notes database 3)In the database expand shared code by clicking on “+” sign next to “Shared Code” Folder and locate webservices as shown in figure 1 Figure 1 4)Click on webservices to see different options like “New Web Service “,”Sign”,”export WSDL” and “show WSDL” as shown in below figure2 Figure2 5)click on “new webservice” to create a new web service 6) It opens a new window with blank webservice as shown in below Figure3 Figure3 7)Enter details like name ,Comment port type class etc , in this case enter Name as ” dbviewformInfo” ,comment as “Delivers information about the structure in a db like actions and other thing” and in port type class “dbInfoClass” and once you enter all this information click on Right Icon to save the name and click on close 8)Go to declarations section in the above saved web service and paste the following code . Please select entire code from starting to ending Const DefaultNameSpace = "reddy.ws.viewformactions" Public Class dbInfoClass Public Function getFormActions(FormDefinition As FormDefinition) As formActionSetInfo Dim w As formActionSetInfo Set w = New formActionSetInfo Call w.PopulateActionsform(FormDefinition) Set getFormActions = w End Function Public Function getViewActions(ViewDefinition As ViewDefinition) As ActionSetInfo Dim x As ActionSetInfo Set x = New ActionSetInfo Call x.PopulateActions(ViewDefinition) Set getViewActions = x End Function End Class Public Class ViewDefinition Public dbName As String Public viewName As String End Class Public Class FormDefinition Public dbName As String Public formName As String Public includeSubForms As Boolean Public IncludeButtons As Boolean End Class Public Class ActionSetInfo Public ActionSets() As ActionInfo Public source As ViewDefinition Public errorCode As Integer Public errorText As String Public Sub PopulateActions(viewSource As ViewDefinition) Set Me.source = viewSource On Error Goto Err_PopulateActions Dim s As New NotesSession Dim db As NotesDatabase Dim dbView As NotesDatabase Dim v As NotesView Set db = s.CurrentDatabase Set dbView = New Notesdatabase(db.Server,viewSource.dbName) Set v = dbView.GetView(viewSource.ViewName) If v Is Nothing Then Me.errorcode = 999 Me.errorText = "The view you were seeking is out of sight, but endless others exist" Goto Exit_PopulateActions End If 'Get the view into DXL and transform Dim viewUnid As String Dim viewDoc As NotesDocument viewUnid =v.UniversalID Set viewDoc=dbView.GetDocumentByUNID(viewUnid) Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim 'REM Export document as DXL exporter As NotesDXLExporter transformer As NotesXSLTransformer domParser As NotesDOMParser docNode As NotesDOMDocumentNode actionNodeList As NotesDOMNodeList actionNode As NotesDOMNode attributes As notesDOMNamedNodeMap nodeCount As Integer i As Integer x As Integer y As Integer Set exporter = s.CreateDXLExporter Set domParser=s.CreateDOMParser Call exporter.SetInput(viewDoc) Call domParser.setInput(exporter) exporter.Process 'get the document node Set docNode = domParser.Document Set actionNodeList = docNode.GetElementsByTagName("action") nodeCount = actionNodeList.NumberOfEntries If nodeCount = 0 Then Msgbox "No actions found" End If Redim ResultArray(nodeCount) Redim Me.ActionSets(nodeCount) For i = 1 To nodeCount Set actionNode = actionNodeList.GetItem(i) Set attributes = actionNode.Attributes x = attributes.NumberOfEntries Dim r As ActionInfo Set r = New ActionInfo For y = 1 To x If attributes.GetItem(y).NodeName="systemcommand" Then r.name =attributes.GetItem(y).NodeValue End If If attributes.GetItem(y).NodeName="title" Then r.label =attributes.GetItem(y).NodeValue End If Next Set Me.ActionSets(i-1) = r Next Exit_PopulateActions: Exit Sub Err_PopulateActions: Me.errorCode = Err Me.errorText = Error$ & " in Line " & Cstr(Erl) Resume Exit_PopulateActions End Sub End Class 'new class for form actions Public Class formActionSetInfo Public ActionSets() As formActionInfo Public source As FormDefinition Public errorCode As Integer Public errorText As String Public Sub PopulateActionsform(FormSource As FormDefinition) Set Me.source = FormSource On Error Goto Err_PopulateActionsForm Dim s As New NotesSession Dim db As NotesDatabase Dim dbView As NotesDatabase Dim Fo As Notesform Dim ncol As NotesNoteCollection Dim FormDoc As NotesDocument Dim FormDocInt As NotesDocument Set db = s.CurrentDatabase Set dbView = New Notesdatabase(db.Server,FormSource.dbName) Set Fo = dbView.GetForm(FormSource.FormName) If Fo Is Nothing Then Me.errorcode = 999 Me.errorText = "The form you were seeking is out of sight, but endless others exist" Goto Exit_PopulateActionsForm End If Dim nid As String, nextid As String 'note IDs Dim i As Integer Set db = s.CurrentDatabase Set ncol = dbView.CreateNoteCollection(False) ncol.SelectForms= True Call ncol.BuildCollection nid = ncol.GetFirstNoteId Set FormDocInt= dbView.GetDocumentByID(nid) 'get access of form as NotesACL document For i = 1 To ncol.Count Forall j In FormDocInt.Items If j.name="$TITLE" Then 'Msgbox j.text If j.text Like "*;*" Then If Strleftback ( j.text,";" )=FormSource.FormName Or Strrightback ( j.text,";" )=FormSource.FormName Then Set FormDoc=FormDocInt End If Else If j.text=FormSource.FormName Then Set FormDoc=FormDocInt End If End If End If End Forall nextid = ncol.GetNextNoteId(nid) If nextid="" Then Set FormDocInt= Nothing Else Set FormDocInt=dbView .GetDocumentByID(nextid) End If nid=nextid Next If FormDoc Is Nothing Then Me.errorcode = 998 Me.errorText = "The form name you were seeking is not matching.please type exactly(case sensitive) as the name exists in form design element" Goto Exit_PopulateActionsForm End If 'Get theforminto DXL and transform 'REM Export document as DXL Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim ' exporter As NotesDXLExporter transformer As NotesXSLTransformer domParser As NotesDOMParser docNode As NotesDOMDocumentNode actionNodeList As NotesDOMNodeList actionNode As NotesDOMNode attributes As notesDOMNamedNodeMap nodeCount As Integer i As Integer x As Integer y As Integer Set exporter = s.CreateDXLExporter Set domParser=s.CreateDOMParser Call exporter.SetInput(FormDoc) Call domParser.setInput(exporter) exporter.Process 'get the document node Set docNode = domParser.Document Set actionNodeList = docNode.GetElementsByTagName("action") nodeCount = actionNodeList.NumberOfEntries If nodeCount = 0 Then Msgbox "No actions found" End If Redim ResultArray(nodeCount) Redim Me.ActionSets(nodeCount) For i = 1 To nodeCount Set actionNode = actionNodeList.GetItem(i) Set attributes = actionNode.Attributes x = attributes.NumberOfEntries Dim r As formActionInfo Set r = New formActionInfo For y = 1 To x 'Msgbox attributes.GetItem(y).NodeName,0,attributes.GetItem(y).NodeValue If attributes.GetItem(y).NodeName="systemcommand" Then r.label =attributes.GetItem(y).NodeValue End If If attributes.GetItem(y).NodeName="title" Then r.name =attributes.GetItem(y).NodeValue End If Next Set Me.ActionSets(i-1) = r Next Exit_PopulateActionsForm: Exit Sub Err_PopulateActionsForm: Me.errorCode = Err Me.errorText = Error$ & " in Line " & Cstr(Erl) Resume Exit_PopulateActionsForm End Sub End Class Public Class ActionInfo Public Name As String Public Label As String End Class Public Class formActionInfo Public Name As String Public Label As String Public Code As String End Class 9) save and close the webservice 10)now you are ready to test the webservice for Testing you can open the webservice in a browser by using following url http://hub.wwcorp.com/PortalConfig.nsf/dbviewformInfo?wsdl this Url contains hostname(hub.wwcorp.com is the server name, PortalConfig.nsf is notes database name and dbviewforminfo is webservice name before “?” mark in the URL you can see WDSL file in the browser. We can also test this in any standard tools from where we can create new SOAP request . use any standard tool (like XML spy, Oxygen xml editor etc ) You need to enter URL of webservice to create a SOAP request for example as shown in below figure 5 http://hub.wwcorp.com/PortalConfig.nsf/dbviewformInfo?wsdl Figure5 please change the hostname, database name accordingly as per your domino setup 11) The SOAP request will show you to options to select as we have two classes one for View actions, and other for view actions, as shown in below figure6 Figure6 12) Select one option and then enter to see the content like shown in below figure 7 Figure 7 here the parameters we need to enter is database name,view name accordingly as shown below example in figure 8 Figure8 13) Once we enter database name and view name then send the the request to server as shown below in figure9 Figure 9 14) Once request is processed by domino server, It will populate all action button details of Given design element name of the given database as shown below in figure10 Figure10 15) Once you have tested and satisfied that it is working fine then we can call the same SOAP request from Portal to pull out required information(View actions or form actions) to Portal Conclusion: Please note that it will only list out all the action buttons ,but it does not get any code /code event related with the action button. there could be several ways to test this webservice. I have shown the simple screenshots to make the basic concept clear Webservice is very vital concept and going to be very popular as different technologies can communicate each other by using a standard webservice and hence domino developer can not ignore this powerful feature The above article shows how we can write our own webservice with simple lotusscript which is mastered technology by Lotus domino devlopers already Similarly we can design and develop several Webservices to suit our customized requirements Srinivas Reddy Kothapally , IBM Certified Application Developer – Lotus Notes and Domino /6.5 and IBM Certified Admin Domino 6/6.5 has been working as a Principal software engineer for ASEAN customer in ISL Labservices in the area of domino and domino extended products. My Special Thanks to My Guru Stephan H Wissel, Stephan H Wissel/Singapore/IBM, who was very instrumental with able guidance in understanding and developing webservices.
© Copyright 2024