gpt4 book ai didi

java - 使用 Spring 在客户端签署 SOAP 请求

转载 作者:行者123 更新时间:2023-11-30 09:40:41 25 4
gpt4 key购买 nike

我已经阅读了有关 Securing your Web services with Spring-WS 的 Spring 文档但它看起来好像这篇文章只是关于服务器端而不是客户端。事实上,它在服务器端使用 Wss4jSecurityInterceptor 工作正常,但我需要签署对外部 Web 服务的请求。

所以,第一个问题。我说得对吗,Spring Web 服务文档的第 7 章仅适用于服务器端?

其次。是否有可能以类似于(简单、优雅)在服务器端完成的方式在客户端使用 Spring 向 SOAP 请求添加安全性(如签名 header )?

我找到了这个 question但看起来签名是用 Apache CXF 和这个 article 完成的签名是以自制方式完成的。

提前致谢。

最佳答案

好吧,恐怕我要回答我自己的问题了:

第一个:。 Spring Web Services 文档的第 7 章是关于客户端和服务器端的。

第二个:根据对第一个问题的回答,,如 Spring Web Services 文档第 7 章所述。

我的错误是我以这种方式声明拦截器:

<sws:interceptors>
<ref bean="wsSecurityInterceptor" />
</sws:interceptors>

这个拦截器只影响服务器端的 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>

关于java - 使用 Spring 在客户端签署 SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9281019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com