Jul
1
After a fair amount of research, experimentation, and poking around, I have finally found a way to return a Domino object (such as a NotesDocument, NotesDocumentCollection, or NotesDatabase) via a Web Service.
Now that I figured it out, it struck me that it’s not something that I’m likely to use because the DXL (Domino XML Language) markup is more complicated than I need. The only scenario I can imagine at this point is if you have a remote Domino server needing a Domino object that is accessible only via a Web Service.
Anyway, it’s worth documenting the process here so I can revisit it later.
For the purpose of this illustration, my code will open the Domino Directory (formerly, the “NAB”) and return the first document found in the People view. It includes some basic error trapping.
Here’s the code:
Public Class co_NotesDocument ' name of the "Port Type Class" ' note that %INCLUDE "lsxsd.lss" is defined in Options ' recommended Web Services tool: SoapUI from soapui.org Public Function getNotesDoc( aFault As WS_FAULT ) As String On Error Goto errHandler ' define basic Domino objects; note the "New" for session Dim s As New NotesSession Dim dbNAB As NotesDatabase Dim viewNAB As NotesView Dim doc As NotesDocument ' special object for exporting the Domino object ' as a DXL thingie Dim exporter As NotesDXLExporter ' instantiate Domino objects for the Notes Address Set dbNAB = New NotesDatabase( "", "names.nsf" ) Set viewNAB = dbNAB.GetView( "People" ) Set doc = viewNAB.GetFirstDocument() ' Define exporter object for current document ' alternately you can define the input document with ' Call exporter.SetInput( doc ) Set exporter = s.Createdxlexporter( doc ) ' return the string of text that is the DXL by assigning ' the Export() method's output the function's name getNotesDoc = exporter.Export( Doc ) Goto Done errHandler: ' If you are using OpenLog.NSF (highly recommended), log ' the error information with LogErrorEx(). This is for ' internal use only (by the Domino developer) ' Call LogErrorEx( "Error " & Err & " in line " & Erl _ ' & ": " & Error$, "ERROR", doc ) ' define the return properties for the fault object ' this is deliberately generic for external users of ' the web service so it reveals less information about ' your infrastructure ' assign actor an arbitrary name; maybe substitute calling user Call aFault.setFaultActor( "CLU Web Service" ) Call aFault.setFaultCode( 1200 ) ' arbitrary fault code ' arbitrary and generic error message returned in the web service Call aFault.setFaultString( "Sorry, this program encountered an " _ & "unexpected error. Ask your app developer to check the logs." ) ' must do this or the fault is NOT returned Call aFault.setFault( True ) Resume Done Done: End Function End Class ' ===================================================================================
Keywords: Returning a NotesDocument from a Web Service, IBM Notes, Lotus Notes, IBM Lotus Notes, IBM Notes Web Services, How to return a Domino object via web service