我有一个 Web 应用程序,它充当使用 Spring WS 实现的 Jax-WS Web 服务的客户端。 Spring WS 配置为需要 SOAP 标头中的用户名令牌。在 Web 应用程序中,我计划使用 Spring Web 服务模板,但我似乎找不到任何示例来说明如何将 UsernameToken 添加到传出请求中。
有人能指出我正确的方向吗?
Thanks.
你必须使用拦截器 http://static.springsource.org/spring-ws/site/reference/html/server.html#server-endpoint-interceptor. See 第 7 章 使用 Spring-WS 保护您的 Web 服务 http://static.springsource.org/spring-ws/site/reference/html/security.html.
配置会是这样的
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="defaultUri"
value="http://localhost:8080/ws-demo/myws" />
<property name="interceptors">
<list>
<ref bean="wsSecurityInterceptor" />
</list>
</property>
</bean>
<bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="securementActions" value="UsernameToken"/>
<property name="securementUsername" value="Ernie"/>
<property name="securementPassword" value="Bert"/>
</bean>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)