天天看点

ehcache的webservice API应用

ehcache提供了两个API,一个是面向资源的RESTful, 另一个SOAP。参见[url]http://ehcache.org/documentation/cache_server.html[/url],官网上有相关介绍。

这两种方式我都是用了,但是当想要实现webservice的安全时却遇到了问题。ehcache使用XWSS 3.0来实现安全的,这里我把所有相关的jar包,从ehcache的war工程拿到客户端来,并且激活war下的server_security_config.xml,此时服务端应该没有问题。但是客户端的调用老是出错。

[quote]2009-10-23 14:05:57 com.sun.xml.wss.impl.SecurityRecipient processMessagePolicy

严重: WSS0253: Message does not conform to configured policy: No Security Header found in message

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Message does not conform to configured policy [ AuthenticationTokenPolicy(S) ]: No Security Header found[/quote]

按照官网给的资料,在客户端的classpath下添加client_security_config.xml,并且在测试main程序里添加

[quote] cacheService = new EhcacheWebServiceEndpointService().getEhcacheWebServiceEndpointPort();

//add security credentials

((BindingProvider)cacheService).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "Ron");

((BindingProvider)cacheService).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "noR");

String result = cacheService.ping();[/quote]

问题暂时没有解决 :oops:

ps:以前使用过wss4j这个组件,在xfire上实现过webservice的安全,但是xfire项目初步废止,现已apache组织接管了[url]http://cxf.apache.org/docs/index.html[/url]