web-services - Spring Web 服务模板 : Add username token

标签 web-services spring jax-ws spring-ws

我有一个 Web 应用程序,它充当使用 Spring WS 实现的 Jax-WS Web 服务的客户端。 Spring WS 配置为需要 SOAP header 中的用户名 token 。在 Web 应用程序中,我计划使用 Spring Web 服务模板,但似乎找不到任何示例来说明如何将 UsernameToken 添加到传出请求。

有人可以指出我正确的方向吗?

谢谢。

最佳答案

您必须使用 Interceptors .见 Chapter 7. Securing your Web services with Spring-WS .

配置将是这样的

<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>

关于web-services - Spring Web 服务模板 : Add username token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9284024/

相关文章:

java - 作为变量传递时,Thymeleaf 片段无法解析,即 <div th :replace ="${page}">

java - JAX WS异步客户端: capture WS-Addressing 202 accepted

java - 如果stream().filter为空

java - 在SDN 5.0.0中创建neo4j sessionfactory

java - 无法使用 Jersey Web 服务

jax-ws - 如何使用 javac 替换 JDK 7 或 6 中已弃用的 wsgen 或 apt?

java - 服务器到客户端通知/Web 服务(jax-ws) 到客户端通信

c# - 如何通过 WebRequest 调用 MVC 操作并通过 Active Directory 验证请求?

java - Spring Security CSRF token 不适用于 AJAX

java - 在没有 EJB 的情况下拦截 SOAP RPC 方法响应