Java 使用Spring在客户端对SOAP请求进行签名
我已经阅读了关于的Spring文档,但在我看来,这篇文章只是关于服务器端,而不是客户端。事实上,使用Wss4jSecurityInterceptor在服务器端运行良好,但我需要签署一个到外部Web服务的请求 第一个问题。我说的对吗?SpringWeb服务文档的第7章只适用于服务器端 第二。使用Spring在客户端向SOAP请求添加安全性(如签名头)是可能的,其方式类似于(简单、优雅)在服务器端的方式 我发现了这一点,但看起来签名是用ApacheCXF完成的,而签名是用自制的方式完成的Java 使用Spring在客户端对SOAP请求进行签名,java,client-side,spring-ws,sign,Java,Client Side,Spring Ws,Sign,我已经阅读了关于的Spring文档,但在我看来,这篇文章只是关于服务器端,而不是客户端。事实上,使用Wss4jSecurityInterceptor在服务器端运行良好,但我需要签署一个到外部Web服务的请求 第一个问题。我说的对吗?SpringWeb服务文档的第7章只适用于服务器端 第二。使用Spring在客户端向SOAP请求添加安全性(如签名头)是可能的,其方式类似于(简单、优雅)在服务器端的方式 我发现了这一点,但看起来签名是用ApacheCXF完成的,而签名是用自制的方式完成的 提前谢谢。
提前谢谢。恐怕我要回答我自己的问题了: 第一个:否。SpringWeb服务文档的第7章是关于客户端和服务器的 第二个:根据第一个问题的答案,是,如SpringWeb服务文档第7章所述 我的错误是,我是这样声明拦截器的:
<sws:interceptors>
<ref bean="wsSecurityInterceptor" />
</sws:interceptors>
<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>
这种拦截器只会影响服务器端Web服务。对于客户,应通过以下方式进行:
<sws:interceptors>
<ref bean="wsSecurityInterceptor" />
</sws:interceptors>
<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>
只是澄清一下:我要做的就是在请求上签名。