Proxying Text Responses

Sample Number

101

Level

Introductory

Description

This sample demonstrates the usage of UltraESB to proxy Text messages/responses

Use Case

I have a service that returns text format responses and I want to proxy this text service and mediate the text responses. The UltraESB can be used to proxy any type of payload, including SOAP 1.1/1.2, XML, Text, HTML, Hessian, EDI, CSV, binary etc.. this example shows how a plain text response of a Servlet could be proxied through the UltraESB.

text proxy

As shown in the above diagram, instead of directly talking to the text service, UltraESB acts as the proxy for all the requests going to the back-end server, making it possible to mediate text responses.

Sample Configuration

The configuration for a text proxy is trivial as it is just a proxy service to forward the messages into the text service back-end and return the response back to the caller.

Proxy service configuration to proxy text responses

 1<u:proxy id="text-proxy">
 2  <u:transport id="http-8280">
 3    <u:property name="ultra.transport.url" value="text-proxy*"/>
 4  </u:transport>
 5  <u:target>
 6    <u:inDestination>
 7      <u:address>http://localhost:9000/service/TextServlet</u:address>
 8    </u:inDestination>
 9    <u:outDestination>
10      <u:address type="response"/>
11    </u:outDestination>
12  </u:target>
13</u:proxy>

The proxy service URL has been specified by the "ultra.transport.url" to be anything starts with the "text-proxy". The request message will be forwarded to the back-end text servlet and the response back to the caller, without any mediation in this case. Adding mediation for the response path is just a matter of adding a out sequence for the target.

Proxy service can handle any content type if not constrained
Unless a content type constraint is forced, a proxy service can handle SOAP, REST, Hessian, JSON, Text or binary etc

In Action

To try out this sample, start the ToolBox and the sample Jetty server within it. The sample server hosts a servlet that outputs plain text. Using the HTTP/S client of the ToolBox, one can issue a GET request to the URL http://localhost:9000/service/TextServlet to get this response directly from the servlet as shown below.

Response from the back-end text servlet

HTTP/1.1 200 OK
Content-Type: text/plain; charset=iso-8859-1
Connection: close
Server: Jetty(8.1.13.v20130916)

Plain text Hello World

Now, start the sample configuration 101 of the UltraESB through the ToolBox, or the command line as follows.

$ cd /opt/ultraesb-2.6.1/bin
$ ./ultraesb.sh -sample 101

Issuing a GET request to the text-proxy of the UltraESB at URL http://localhost:8280/service/text-proxy you will now get the same response through the UltraESB.

Response from the ESB

HTTP/1.0 200 OK
Content-Type: text/plain; charset=iso-8859-1
Date: Web, 17 Aug 2016  05:51:10 GMT
Server: UltraESB/2.6.1
Content-Length: 23
Connection: close

Plain text Hello World

Note that the advantage would be in mediating the request and response, performing transformations or other such actions via the UltraESB.

Related Samples

Sample Number

Sample Title

101

Restful Proxy Services

201

Proxying SOAP Messages

In this topic
In this topic
Contact Us