Domino Web Service: Part 2


Создаем Web Service Consumers

назовем приемник importer он описывает процедуру UPLOAD с двумя параметрами: docid — UNID импортируемого документа и V — собственно массив информации закодированный в BASE64

%INCLUDE «lsxsd.lss»
Class Wsdl As PortTypeBase

Sub NEW
Call Service.Initialize («UrnDefaultNamespacewsdlService», _
«wsdlService.Domino», «http://sitename/importer?OpenWebService», _
«Wsdl»)

End Sub

Function UPLOAD(DOCID As String, V As XSD_BASE64BINARY) As XSD_ANYTYPE
Set UPLOAD = Service.Invoke(«UPLOAD», DOCID, V)
End Function

End Class

Создаем агента который будет проходить по всем документам базы и на каждом документе вызывать Web Service для «заливки» документа на хостинг.

%REM
Agent upload
Created Mar 31, 2014 by Admin/SRO
Description: Comments for Agent

%END REM
Option Public
Option Declare

Use «export»
Sub Initialize
On Error GoTo ErrHandler
Dim s As New NotesSession
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = s.Currentdatabase
Set dc = db.Alldocuments

Dim v As XSD_BASE64BINARY
Dim exporter As NotesDXLExporter
Dim stream As NotesStream
Dim tmpstream As NotesStream
Dim ws As Wsdl

Set v = New XSD_BASE64BINARY
Set stream = s.CreateStream
Set ws = New Wsdl

Set doc = dc.Getfirstdocument()
While Not doc Is Nothing
‘вызов для экспорта
Set exporter = s.CreateDXLExporter(doc, stream)
exporter.Doctypesystem = «xmlschemas/domino_8_5_2.dtd»
Call exporter.Process
Call v.Setvaluefromnotesstream(stream)
call ws.Upload(doc.Universalid, v)
Call stream.Truncate()
Set doc = dc.Getnextdocument(doc)
Wend
Call stream.Close
End 200
ErrHandler:
Print «Agent export2site:»+ CStr(Err) + » line:» + CStr(Erl)
Resume Next
End Sub