Spring WS - Part 3

Now let's go into little details of the whole App
So from the Client Controller, we invoke the service with the help of WebServiceTemplate after contructing appropiate request model. The configuration for WebServiceTemplate can be found in SpringWSApplicationConfig.java. It can be seen that in the request model we are attaching a file. We have used MTOM here for the attachment purpose, which we will discuss in detail in upcoming posts.

So the requuest before reaching the specified endping, which is being determined by EndpintMapping implementation passes through a series of interceptors configured in SpringWSApplicationConfig.java in addInterceptors bean.

I have used here two Spring WS in-built interceptors:
1) SoapEnvelopeLoggingInterceptor.java
2) PayloadLoggingInterceptor.java
They are basically logging interceptors and one Custom interceptor i.e. CountryInterceptor.java
The code for Custom interceptor is already provided above.
Now to use Custom interceptor we need to wrap in into PayloadRootSmartSoapEndpointInterceptor. We can also specify the namespace and the payload of the request for which the interceptor would get invoked just the same as we can do from Service endpoint with the help of @PayloadRoot annotation.

So after the interceptors has finished processing, anf if there is no problem (true is returned from the method) then the request would go to Service endpoint, had there been any problem (false is returned from the method), then the request wont reach the service endpoint.

Once the request reaches the service endpoint based on the namespace and the payload of the request, the appropiate method is invoked and response is retuned back to the client. Had there been any exception, as described in the above Service Endpoint code, then SOAP fault is returned. Please note we cannot declare two methods within the Service Endpoint having identical namespace and the payload, as in this case there would be exception during startup.

Fault Handling in Spring WS can be configured with the help of Exception Resolvers
. We will also see to it :-)

MTOM with Spring WS

Comments

Popular posts from this blog

Use of @Configurable annotation.

Spring WS - Part 5

Spring WS - Part 4