Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected links that should have been relative instead of absolute.
Sample Number101
LevelIntroductory
DescriptionThis sample demonstrates the usage of UltraESB to proxy Text messages/responses

Table of Contents

Use Case

Excerpt

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.

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.

Code Block
titleProxy service configuration to proxy text responses
themeEclipse
linenumberstrue
languagehtml/xml
<u:proxy id="text-proxy">
  <u:transport id="http-8280">
    <u:property name="ultra.transport.url" value="text-proxy*"/>
  </u:transport>
  <u:target>
    <u:inDestination>
      <u:address>http://localhost:9000/service/TextServlet</u:address>
    </u:inDestination>
    <u:outDestination>
      <u:address type="response"/>
    </u:outDestination>
  </u:target>
</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.

Info
titleProxy 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.

Panel
bgColor#EEEEFF
titleBGColor#E0E0D0
titleResponse from the back-end text servlet
borderColor#BBBBBB
HTTP/1.1 200 OK
Content-Type: text/plain; charset=iso-8859-1
Connection: close
Server: Jetty(6.1.21)

Plain text Hello World

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

Code Block
themeEclipse
languagebash
$ cd /opt/ultraesb-1.6.0/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.

Panel
bgColor#EEEEFF
titleBGColor#E0E0D0
titleResponse from the ESB
borderColor#BBBBBB
HTTP/1.0 200 OK
Content-Type: text/plain; charset=iso-8859-1
Date: Wed, 13 Jan 2010 05:51:10 GMT
Server: UltraESB/1.6.0
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 NumberSample Title
101Restful proxy services
201Proxying SOAP messages