XFire wssecurity 实现用户名密码验证 出错。高手请进
时间:2011-12-06
来源:互联网
public static void main(String[] args) {
try
{
String serviceURL = "http://localhost:8080/WebStudy/services/TestHelloService";
Service srvcModel = new ObjectServiceFactory().create(ITestHelloService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
ITestHelloService service = (ITestHelloService)factory.create(srvcModel,serviceURL);
Client client = Client.getInstance(service);
client.addOutHandler(new DOMOutHandler());
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
properties.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
//添加用户名:
properties.setProperty(WSHandlerConstants.USER,"admin");
properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName()); properties.setProperty(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
client.addOutHandler(new WSS4JOutHandler(properties));
System.out.println(service.sayHello("Web Service"));
}
catch(Exception ex)
{
System.out.println(ex);
}
}
上面那是客户端调用的代码,红色部分编译不过去,
因为这个PasswordHandler类是服务器端定义的,这个代码是客户端的,所以找不到。
但是我从网上查了好多,大家都是这么用的,我想问一下,这个地方应该怎么修改。
try
{
String serviceURL = "http://localhost:8080/WebStudy/services/TestHelloService";
Service srvcModel = new ObjectServiceFactory().create(ITestHelloService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
ITestHelloService service = (ITestHelloService)factory.create(srvcModel,serviceURL);
Client client = Client.getInstance(service);
client.addOutHandler(new DOMOutHandler());
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
properties.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
//添加用户名:
properties.setProperty(WSHandlerConstants.USER,"admin");
properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName()); properties.setProperty(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
client.addOutHandler(new WSS4JOutHandler(properties));
System.out.println(service.sayHello("Web Service"));
}
catch(Exception ex)
{
System.out.println(ex);
}
}
上面那是客户端调用的代码,红色部分编译不过去,
因为这个PasswordHandler类是服务器端定义的,这个代码是客户端的,所以找不到。
但是我从网上查了好多,大家都是这么用的,我想问一下,这个地方应该怎么修改。
作者: princesshan 发布时间: 2011-12-06
我记得本地是要实现这个类的吧
作者: ifandui 发布时间: 2011-12-06
本地和服务器都要实现这个类吗?
为什么那?
为什么那?
作者: princesshan 发布时间: 2011-12-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28