Saturday, August 31, 2013

WSO2 ESB - Adding complex SOAP headers to a message

WSO2 ESB comprises of about 40+ mediators, using which you can perform several actions on the the SOAP messages being passed through. One such requirement would be to manipulate SOAP headers of a message.


What if you need to add a complex header structure to the message as follows,



A real use case of this kind of a requirement will be, you have a secured proxy service in ESB with UsernameToken Policy applied, but the backend service is not secured according to WSSE standards, but having its own way of authenticating, hence it requires messages coming to that endpoint having the structure of the headers as above, and username and password header values need to set with the username and password contains in the WSSE usernameToken of the original request.

That can be achieved using a class / custom mediator which involves writing some Java code, but if you need to avoid deploying / maintain a separate package for that you can chose either Header mediator, XSLT mediator or Script mediator.

Here I'm going to show how the script mediator can be used for the above use case.

Since you have enabled WS security in the proxy service, a valid SOAP request needs to contain the WSSE security headers, as follows.


As highlighted in the above request message, you have to extract the username and password values coming in the request and set those in the header structure which is expected by the backend service.

In order to do that your Script Mediator configuration will be as follows,

That's it..! If you do a full log in insequence you will see the message with added complex headers.. In a future post I Will show you how to use Header mediator and XSLT mediator to achieve the same task.

References
[1] http://docs.wso2.org/display/ESB470/Script+Mediator
[2] http://wso2.com/project/mashup/0.2/docs/e4xquickstart.html

Saturday, March 2, 2013

If your laptop's touchpad suddenly stopped working...

If you are working in Linux (Ubuntu) execute the following command,

   gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true