{"id":129,"date":"2014-07-01T19:00:28","date_gmt":"2014-07-02T02:00:28","guid":{"rendered":"http:\/\/blogs.callutheran.edu\/jpdillon\/?p=129"},"modified":"2014-07-02T14:21:51","modified_gmt":"2014-07-02T21:21:51","slug":"returning-a-notes-document-from-a-web-service","status":"publish","type":"post","link":"https:\/\/blogs.callutheran.edu\/jpdillon\/2014\/07\/01\/returning-a-notes-document-from-a-web-service\/","title":{"rendered":"Returning a Notes Document from a Web Service"},"content":{"rendered":"<p>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.<\/p>\n<p>Now that I figured it out, it struck me that it&#8217;s not something that I&#8217;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.<\/p>\n<p>Anyway, it&#8217;s worth documenting the process here so I can revisit it later.<\/p>\n<p>For the purpose of this illustration, my code will open the Domino Directory (formerly, the &#8220;NAB&#8221;) and return the first document found in the People view.\u00a0 It includes some basic error trapping.<\/p>\n<p>Here&#8217;s the code:<\/p>\n<pre>\u00a0Public Class co_NotesDocument ' name of the \"Port Type Class\"\r\n\r\n\u00a0\u00a0 \u00a0' note that %INCLUDE \"lsxsd.lss\" is defined in Options\r\n\u00a0\u00a0 \u00a0' recommended Web Services tool: SoapUI from soapui.org\r\n\r\n\u00a0\u00a0 \u00a0Public Function getNotesDoc( aFault As WS_FAULT ) As String\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0On Error Goto errHandler\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' define basic Domino objects; note the \"New\" for session\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Dim s As New NotesSession\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Dim dbNAB As NotesDatabase\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Dim viewNAB As NotesView\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Dim doc As NotesDocument\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' special object for exporting the Domino object \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' as a DXL thingie\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Dim exporter As NotesDXLExporter\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' instantiate Domino objects for the Notes Address\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Set dbNAB = New NotesDatabase( \"\", \"names.nsf\" )\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Set viewNAB = dbNAB.GetView( \"People\" )\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Set doc = viewNAB.GetFirstDocument()\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' Define exporter object for current document\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' alternately you can define the input document with \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' Call exporter.SetInput( doc )\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Set exporter = s.Createdxlexporter( doc )\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' return the string of text that is the DXL by assigning\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' the Export() method's output the function's name\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0getNotesDoc = exporter.Export( Doc )\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Goto Done \r\n\r\nerrHandler:\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' If you are using OpenLog.NSF (highly recommended), log \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' the error information with LogErrorEx().\u00a0 This is for \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' internal use only (by the Domino developer)\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' Call LogErrorEx( \"Error \" &amp; Err &amp; \" in line \" &amp; Erl _ \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' &amp; \": \" &amp; Error$, \"ERROR\", doc ) \r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' define the return properties for the fault object\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' this is deliberately generic for external users of \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' the web service so it reveals less information about\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' your infrastructure\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' assign actor an arbitrary name; maybe substitute calling user\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Call aFault.setFaultActor( \"CLU Web Service\" ) \r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Call aFault.setFaultCode( 1200 ) ' arbitrary fault code\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' arbitrary and generic error message returned in the web service\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Call aFault.setFaultString( \"Sorry, this program encountered an \" _\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&amp; \"unexpected error. Ask your app developer to check the logs.\" )\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0' must do this or the fault is NOT returned\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Call aFault.setFault( True )\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Resume Done\r\nDone:\r\n\r\n\u00a0\u00a0 \u00a0End Function\r\nEnd Class ' ===================================================================================<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #cc99ff\">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<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s not something that I&#8217;m likely to use because the DXL (Domino XML [&hellip;]<\/p>\n","protected":false},"author":10785,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-ibm-notes-lotus-notes"],"_links":{"self":[{"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/users\/10785"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":4,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/posts\/129\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.callutheran.edu\/jpdillon\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}