Spring Web服务模板:添加用户名令牌 [英] Spring Web Service Template: Add username token

查看:125
本文介绍了Spring Web服务模板:添加用户名令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a web app that acts as a client to a Jax-WS web service implemented using Spring WS. The Spring WS is configured to require a username token in the SOAP header. In the web app I plan to use the Spring web service template but I can't seem to find any examples which show how to add a UsernameToken to the outgoing request.

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

Can someone point me in the right direction?

谢谢.

推荐答案

您必须使用第7章.使用Spring-WS保护Web服务.

配置将如下所示

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

这篇关于Spring Web服务模板:添加用户名令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆