Lotus|Lotus domino 8.5 WebService 二 (LotusScript消费WebService)

开发工具:
MyEclipse 8
【Lotus|Lotus domino 8.5 WebService 二 (LotusScript消费WebService)】Lotus Domino 8.5
平台:
Windows
XFire1.2 (WebService)

1. 新建web工程
2. 用MyEclipse自动导入XFire包
3. 创建测试类
接口:IUserInfo.java
实现类:UserInfoImpl.java
4.代码:
-------------------------------
IUserInfo.java:
public interface IUserInfo {

public String getUserInfoXml(int iID);

}
-------------------------------
UserInfoImpl.java:

public class UserInfoImpl implements IUserInfo {

public String getUserInfoXml(int iUserID) {
StringBuffer infoBuffer = new StringBuffer("");
if(iUserID>0){
infoBuffer.append("user id is").append(iUserID);
}else{
infoBuffer.append("no user id");
}
return infoBuffer.toString();
}
}
5. 让MyEclipse自动创建WebService Client
生成后类如图:

6. 测试WebService服务http://localhost:8080/XFireDemo91/services/UserInfo?wsdl,并另存为UserInfo.wsdl文件以备用。
7. domino中新建代理WebService使用者UserInfoLotusService:
新建使用者,输入http://localhost:8080/XFireDemo91/services/UserInfo?wsdl,会自动创建service代码:


%INCLUDE "lsxsd.lss"
Const n0 = "http://service.sxwd.com"
Class UserInfoPortType_n0 As PortTypeBase

Sub NEW
Call Service.Initialize ("HttpServiceSxwdComUserInfo", _
"UserInfo.UserInfoHttpPort", "http://localhost:8080/XFireDemo91/services/UserInfo", _
"UserInfoPortType_n0")

End Sub

'注意这个地方返回的是XSD_STRING类型,在java中返回的是String类型
Function getUserInfoXml(in0 As Long) As XSD_STRING
Set getUserInfoXml = Service.Invoke("getUserInfoXml", in0)
End Function

End Class
8. 新建代理,调用WebService使用者:
'--------------------
Option Public
Option Declare
Use "UserInfoLotusService"
'--------------------
Sub Initialize
Dim session As New NotesSession

Dim service As UserInfoPortType_n0
Set service = New UserInfoPortType_n0

'定义为Xsd_string,在ls中式自定义类型
Dim result As Xsd_string


Set result = service.getUserInfoXml(3)
'将Xsd_string类型的结果转为String类型,输出
Msgbox result.Getvalueasstring()

End Sub

9. 执行此代理,输出user id is 3成功!

    推荐阅读