This interceptor adds a SOAP header to incoming request using the Java DOM API.
To run the example execute the following steps:
- Goto the examples/soap11/add-soap-header directory
- Run below command
mvn package
- Execute
service-proxy.bat
orservice-proxy.sh
- Open a second terminal
- Run below command
curl -d @soap-message-without-header.xml http://localhost:2000 -H "Content-Type: application/xml"
- On the console you will see that a security XML-element gets added to the request of the body
Using maven, we create a jar file and copy the compiled jar file into the libs directory of membrane to make the new interceptor available to the router.
In the proxies.xml file, we define a name for our interceptor and write its fully qualified name, so we can use our interceptor on `. You can see it in the line below.
<spring:bean id="headerAddInterceptor" class="com.predic8.AddSoapHeaderInterceptor" />
Again in the proxies.xml file inside <serviceProxy>
tag you can see that we added the interceptor using the beanname we defined above.
<serviceProxy name="echo" port="2000">
<interceptor refid="headerAddInterceptor"/>
The add header interceptor checks if the content of the request is xml and the existence of a Header element. If both conditions are met it adds a Security element to the SOAP header. Have a look at the AddSoapHeaderInterceptor source code as well.
Also, you might notice the groovy interceptor. This is just used for sending a request back. Usually there is a target-Element instead.