norder to configure a proxy for an existing web application you need to set up binary relay, which allows users to send messages to differant parties at byte level while making decicions using transport headers. It further enables to passthrough SOAP messages without performing heavy XML parsing. Here are the steps to expose a webapplication through WSO2 ESB.
1. Enable the message relay module.
Go to ESB management console and go to Manage --> Modules --> List and click on engage icon associated with relay module to engage the module globally.
2. Configure message formatters and message builders in axis2.xml
Go to repository-->conf and edit the axis2 xml. Uncomment the nessary messageFormatters, messageBuilders as shown below.
<messageFormatters> <!--JSON Message Formatters--> <messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/> <messageFormatter contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/> <messageFormatter contentType="text/javascript" class="org.apache.axis2.json.JSONMessageFormatter"/> <messageFormatter contentType="application/x-www-form-urlencoded" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="multipart/form-data" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="application/xml" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="text/html" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="application/soap+xml" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="text/xml" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="x-application/hessian" class="org.apache.synapse.format.hessian.HessianMessageFormatter"/> <messageFormatter contentType="" class="org.apache.synapse.format.hessian.HessianMessageFormatter"/> </messageFormatters>
<messageBuilders> <messageBuilder contentType="application/xml" class="org.apache.axis2.builder.ApplicationXMLBuilder"/> <messageBuilder contentType="application/x-www-form-urlencoded" class="org.apache.axis2.builder.XFormURLEncodedBuilder"/> <messageBuilder contentType="multipart/form-data" class="org.apache.axis2.builder.MultipartFormDataBuilder"/> <!--JSON Message Builders--> <messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/> <messageBuilder contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/> <messageBuilder contentType="text/javascript" class="org.apache.axis2.json.JSONOMBuilder"/> <messageBuilder contentType="application/xml" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="application/x-www-form-urlencoded" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="multipart/form-data" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="multipart/related" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="application/soap+xml" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="text/plain" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="text/xml" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="x-application/hessian" class="org.apache.synapse.format.hessian.HessianMessageBuilder"/> <messageBuilder contentType="" class="org.apache.synapse.format.hessian.HessianMessageBuilder"/> </messageBuilders>
Save axis2.xml and restart the server to affect the axis2.xml changes.
3.Creating the proxy service.
Go to ESB management console and create a pass through proxy service by giving the target endpoint as your webapplication url.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="amt"
transports="http" statistics="disable" trace="enable" startOnLoad="true"> <target> <outSequence> <send /> </outSequence> <endpoint> <address uri="http://localhost/webapp/index.html"
format="get" /> </endpoint> </target> </proxy>
You can now access your proxy service through esb port. ie http://localhost:8282/services/MyProxyService1
No comments:
Post a Comment