Notes, Domino, WebService, Service
Sample WebService in ND7:
Dim s As notesSession
Dim db As notesDatabase
Class arTitles
Public ar() As String
End Class
Class docInfo
Sub NEW ()
Set s = New notesSession
Set db = s.CurrentDatabase
End Sub
Public Function getAllDocs () As arTitles
Dim n As Integer, vw As notesView, doc As notesDocument, sTitle As String
Set getAllDocs = New arTitles()
Set vw = db.GetView("vwMain")
Set doc = vw.GetFirstDocument()
n = -1
While Not (doc Is Nothing)
n = n + 1
sTitle = doc.docTitle(0)
Redim Preserve getAllDocs.ar(0 To n)
getAllDocs.ar(n) = sTitle
Set doc = vw.GetNextDocument(doc)
Wend
End Function
Public Function getSingleDocAbstractByTitle (sTitle As String) As String
Dim docIn As notesDocument
Set docIn = s.DocumentContext
sLang = getLangFromHeader (docIn, "English")
Dim vw As notesView, doc As notesDocument, sAbstract As String
Set vw = db.GetView("vwMain")
Set doc = vw.GetDocumentByKey (sTitle, True)
If (doc Is Nothing) Then
Msgbox "Nothing found. (" + sTitle + ")"
getSingleDocAbstractByTitle = "Document could not be found."
Else
Msgbox "Something found. (" + sTitle + ")"
Select Case sLang
Case "English"
getSingleDocAbstractByTitle = doc.docAbstract(0)
Case "Spanish"
getSingleDocAbstractByTitle = doc.docAbstract_es(0)
Case Else
getSingleDocAbstractByTitle = doc.docAbstract(0)
End Select
End If
Msgbox "Web service Returning: " + getSingleDocAbstractByTitle
End Function
Private Function getLangFromHeader (doc As notesDocument, sDefault As String) As String
Dim sXML As String
On Error Goto getLangFromHeader_err
If (doc Is Nothing) Then
getLangFromHeader = sDefault
Exit Function
End If
sXML = doc.Request_Content(0)
If (sXML = "") Then
getLangFromHeader = sDefault
Exit Function
End If
Dim s As New notesSession, dp As notesDOMParser, root As notesDOMDocumentNode, nodeList As NotesDOMNodeList, n As Integer
Dim nodeLang As notesDOMNode, nodeLangText As notesDOMNode
Set dp = s.CreateDOMParser (sXML)
Call dp.Parse
Set root = dp.Document
Set nodeList = root.GetElementsByTagName("sLang")
n = nodeList.NumberOfEntries
If (n <= 0) Then
getLangFromHeader = sDefault
Exit Function
End If
Set nodeLang = nodeList.GetItem(1)
Set nodeLangText = nodeLang.FirstChild
If (nodeLangText.IsNull) Then
getLangFromHeader = sDefault
Exit Function
End If
getLangFromHeader = nodeLangText.NodeValue
Exit Function
getLangFromHeader_err:
getLangFromHeader = "Error: (" + Cstr(nLine) + ") " + Error$
Exit Function
End Function
End Class
Sample WebService in ND7:
Dim s As notesSession
Dim db As notesDatabase
Class arTitles
Public ar() As String
End Class
Class docInfo
Sub NEW ()
Set s = New notesSession
Set db = s.CurrentDatabase
End Sub
Public Function getAllDocs () As arTitles
Dim n As Integer, vw As notesView, doc As notesDocument, sTitle As String
Set getAllDocs = New arTitles()
Set vw = db.GetView("vwMain")
Set doc = vw.GetFirstDocument()
n = -1
While Not (doc Is Nothing)
n = n + 1
sTitle = doc.docTitle(0)
Redim Preserve getAllDocs.ar(0 To n)
getAllDocs.ar(n) = sTitle
Set doc = vw.GetNextDocument(doc)
Wend
End Function
Public Function getSingleDocAbstractByTitle (sTitle As String) As String
Dim docIn As notesDocument
Set docIn = s.DocumentContext
sLang = getLangFromHeader (docIn, "English")
Dim vw As notesView, doc As notesDocument, sAbstract As String
Set vw = db.GetView("vwMain")
Set doc = vw.GetDocumentByKey (sTitle, True)
If (doc Is Nothing) Then
Msgbox "Nothing found. (" + sTitle + ")"
getSingleDocAbstractByTitle = "Document could not be found."
Else
Msgbox "Something found. (" + sTitle + ")"
Select Case sLang
Case "English"
getSingleDocAbstractByTitle = doc.docAbstract(0)
Case "Spanish"
getSingleDocAbstractByTitle = doc.docAbstract_es(0)
Case Else
getSingleDocAbstractByTitle = doc.docAbstract(0)
End Select
End If
Msgbox "Web service Returning: " + getSingleDocAbstractByTitle
End Function
Private Function getLangFromHeader (doc As notesDocument, sDefault As String) As String
Dim sXML As String
On Error Goto getLangFromHeader_err
If (doc Is Nothing) Then
getLangFromHeader = sDefault
Exit Function
End If
sXML = doc.Request_Content(0)
If (sXML = "") Then
getLangFromHeader = sDefault
Exit Function
End If
Dim s As New notesSession, dp As notesDOMParser, root As notesDOMDocumentNode, nodeList As NotesDOMNodeList, n As Integer
Dim nodeLang As notesDOMNode, nodeLangText As notesDOMNode
Set dp = s.CreateDOMParser (sXML)
Call dp.Parse
Set root = dp.Document
Set nodeList = root.GetElementsByTagName("sLang")
n = nodeList.NumberOfEntries
If (n <= 0) Then
getLangFromHeader = sDefault
Exit Function
End If
Set nodeLang = nodeList.GetItem(1)
Set nodeLangText = nodeLang.FirstChild
If (nodeLangText.IsNull) Then
getLangFromHeader = sDefault
Exit Function
End If
getLangFromHeader = nodeLangText.NodeValue
Exit Function
getLangFromHeader_err:
getLangFromHeader = "Error: (" + Cstr(nLine) + ") " + Error$
Exit Function
End Function
End Class