日期:2014-05-17  浏览次数:20829 次

XFire wssecurity 实现用户名密码验证 出错。高手请进
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类是服务器端定义的,这个代码是客户端的,所以找不到。

但是我从网上查了好多,大家都是这么用的,我想问一下,这个地方应该怎么修改。

------解决方案--------------------
我记得本地是要实现这个类的吧