2

我正在尝试使用 Spring-WS 编写我的第一个客户端,并且对一些基础知识感到有些困惑。我需要在标头中插入一个 SAML 令牌,并且我注意到 WebServiceTemplate 类允许拦截器和 WebServiceMessageCallbacks。

有人可以帮我理解为什么我应该使用一个与另一个吗?

其次,我注意到 WST 类允许一个拦截器列表,但只有一个回调。有谁知道这个设计决策背后的逻辑是什么?为什么无法传递回调数组或列表?

谢谢,

埃里克

4

1 回答 1

3

I was wondering the same after reading your question (-:

On this link there's a brief explanation and that's exactly how I use both. For instance, for a specific request I need to set the SOAP action:

JAXBElement<Response> response = (JAXBElement<Response>) webserviceTemplate.marshalSendAndReceive(
    request, 
    new SoapActionCallback("PutOrganisationUnitRequest")
);

This is indeed a simple, anonymous class as mentioned in the link. An interceptor on the other hand is defined and used for all requests. Take a look at XwsSecurityInterceptor for instance, I use that to set the authentication on ALL requests.

于 2012-07-02T13:54:07.903 回答