Spring Web Services

Exercise: Todo SOAP Service (Interceptors)

The objective of this exercise is to add Apache CXF Interceptors to the SOAP-based todo web service and client.

Assignment

  1. Logging Interceptors
  2. Authentication Outbound Interceptor
    • Derive the AuthOutInterceptor from the AbstractSoapInterceptor and add it to the PRE_PROTOCOL phase using the base constructor.
    • Implement the handleMessage that adds a header with a security token to outgoing SOAP messages
      Header header = new Header(name, token, new JAXBDataBinding(String.class));
      message.getHeaders().add(header);
    • In the WebClientConfig class, add the interceptor to the client proxy of the web service
      ClientProxy.getClient(proxy).getOutInterceptors().add(interceptor);
  3. Authentication Inbound Interceptor
    • Derive the AuthInInterceptor from the AbstractSoapInterceptor and add it to the POST_PROTOCOL phase using the base constructor.
    • Implement the handleMessage that reads the header of incoming SOAP messages, verifies the contained security token and throws a Fault exception if the token is not valid
      Header header = message.getHeader(name);
      String token = ((Element) header.getObject()).getTextContent();
    • In the WebServiceConfig class, add the interceptor to the endpoint of the web service
      endpoint.getInInterceptors().add(interceptor);

Solution Service
Solution Client