【背景】
随着web系统业务的深入开发,与第三方系统集成的需求越来越多,系统之间集成的方法也比较多,如通过jdbc、odbc直接与关系数据库进行增、删、改操作,本文主要介绍通过webservice与第三方系统集成方法。
【基础要求】
1、Webservice提供者(designer7版本叫web服务)
domino服务器:7以上版本
designer客户端:7以上版本
2、webservice使用者
domino服务器:8以上版本
designer客户端:8以上版本
【webservice提供者】
供第三方系统调用与domino系统集成的webservice接口。
新建步骤如下:
Designer客户端-->数据库-->代码-->Web Service提供者-->新建
WebService属性见截图:
参考代码:
Class OAType
Public sTypeID As String '类型编码
Public sTypeName As String '类型名称
End Class
Class ImportOAType
Private session As NotesSession
Private db As NotesDatabase
Sub new
Set session = New NotesSession
Set db = session.CurrentDatabase
End Sub
Public Function createType(arrType() As OAType) As Boolean
On Error Goto errHandle
Dim i As Integer
Dim doc As NotesDocument
createType = False
For i=0 To Ubound(arrType)
Set doc = db.CreateDocument()
doc.Form = "WebserviceEmpForm"
doc.StTypeID = arrType(i).sTypeID
doc.StTypeName = arrType(i).sTypeName
Call doc.Save(True,False)
Next
createType = True
Exit Function
errhandle:
Msgbox "createType函数出错,出错信息:" & Error & ",出错行:" & Cstr(Erl())
Exit Function
End Function
End Class
webservice地址:http://<服务器地址>/<数据库路径>/<webservice提供者>?wsdl
建议数据库ACL支持anonymous,否则调用时还需提供用户名、密码。
【webservice使用者】
domino调用第三方系统的webservice接口。
新建步骤如下:
1、Designer客户端-->数据库-->代码-->Web Service使用者-->新建
2、选择“指向WSDL文件的URL”,并输入webservice的wsdl地址
点击确定,生成Web Service使用者的设计元素,可直接在代理中引用,类似于脚本库的功能,参见下面调用webservice代码:Use "testweb3"。
【调用webservice代码】
%REM
Agent ExecuteWebservice
Created 2012-6-13
Description: Comments for Agent
%END REM
Option Public
Option Declare
Use "testweb3"
Sub Initialize
On Error GoTo errhandle
Dim ss As New NotesSession
Dim i As Integer
Dim arrOaType(1) As Oatype
For i=0 To UBound(arrOaType)
Set arrOaType(i) = New Oatype
arrOaType(i).Stypeid = "000" & i
arrOaType(i).Stypename = "类型" & i
MsgBox "i==" & i
Next
Dim createType As New Importoatype
Dim bReturn As Boolean
Call createType.Createtype(arrOaType)
'bReturn = createType.Createtype(arrOaType)
MsgBox "成功!"
Exit Sub
errhandle:
MsgBox ss.CurrentDatabase.FilePath + "数据库中的"+ ss.CurrentAgent.name+"代理的 Initialize 方法发生错误:"+Error + ", 错误行号:" + CStr(Erl())
Exit sub
End Sub
这样子看来,是不是webservice也没有那么神秘了?
数据库下载链接:点击打开链接