第十九章 添加时间戳和用户名令牌 - 时间戳和用户名令牌示例
时间戳和用户名令牌示例
此示例显示了一个需要密码验证的 Web 服务,以及一个在其请求消息中发送时间戳和用户名令牌的 Web 客户端。
注意:此示例以明文形式发送用户名和密码。
为了使此示例在自己的环境中运行,请首先执行以下操作:
- 对于
Web服务所属的Web应用程序,将该应用程序配置为仅支持密码验证:
- 从管理门户主页,选择系统管理 > 安全 > 应用程序 > Web 应用程序。
- 选择 Web 应用程序。
- 仅选择密码选项,然后选择保存。
- 如果不使用默认设置,请编辑客户端以使用适当的 IRIS 用户名和密码。
Web服务如下:
Class Tokens.DivideWS Extends %SOAP.WebService
{
Parameter SECURITYIN = "REQUIRE";
/// Name of the Web service.
Parameter SERVICENAME = "TokensDemo";
/// SOAP namespace for the Web service
Parameter NAMESPACE = "http://www.myapp.org";
/// Divide arg1 by arg2 and return the result. In case of error, call ApplicationError.
Method Divide(arg1 As %Numeric = 2, arg2 As %Numeric = 8) As %Numeric [ WebMethod ]
{
Try {
Set ans=arg1 / arg2
}Catch{
Do ..ApplicationError("division error")
}
Quit ans
}
/// Create our own method to produce application specific SOAP faults.
Method ApplicationError(detail As %String)
{
//details not shown here
}
}
.png)
