我已经创建了一个CXF JAXWS服务,如下所示。
我提供了一个自定义的UserNameToken验证器和一个回调处理程序。
但这不起作用。它每次都会抛出一个错误。
<http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
<cxf:jaxws-service serviceClass="com.example.service.HelloServiceImpl" >
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken" />
</cxf:ws-config>
<cxf:ws-custom-validator >
<cxf:username-token-validator ref="customUsernameTokenValidator" />
</cxf:ws-custom-validator>
</cxf:ws-security>
<cxf:properties>
<spring:entry key="ws-security.ut.validator" value-ref="customUsernameTokenValidator" ></spring:entry>
<spring:entry key="ws-security.callback-handler" value-ref="myPasswordCallback" ></spring:entry>
</cxf:properties>
.....
.....
我的WSDL绑定策略如下
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<wsp:Policy />
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
当我使用usernametoken和密码从SOAPUI发出请求时,我收到以下错误。
2013-04-10 11:08:13,811 WARN [qtp1221956599-40 - /HelloService] logging.LogUtils (LogUtils.java:384) - Interceptor for {http://example.org/HelloService}ProductSOAPService#{http://example.org/HelloService}addCompany has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault
at org.mule.module.cxf.MuleInvoker.invoke(MuleInvoker.java:106)
at org.mule.module.cxf.MuleJAXWSInvoker.invoke(MuleJAXWSInvoker.java:47)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
.....
.....
Caused by: java.lang.NullPointerException
at org.mule.module.cxf.MuleInvoker.invoke(MuleInvoker.java:60)
... 29 more
请帮助我理解我在这里失踪的内容。
注意:我尝试过使用cxf:ws-security在jaxws上实现安全性的Mule方法,我的服务正在运行并给出正确的响应。
答案 0 :(得分:1)
您的cxf jaxws-service应如下所示。然后它应该工作。
<http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
<cxf:jaxws-service serviceClass="com.example.service.HelloServiceImpl" >
<cxf:properties>
<spring:entry key="ws-security.ut.validator" value-ref="customUsernameTokenValidator" ></spring:entry>
<spring:entry key="ws-security.callback-handler" value-ref="myPasswordCallback" ></spring:entry>
</cxf:properties>
</cxf:jaxws-service>