Skip to content

Messaging API and templating engine

JGuillemotte edited this page Feb 2, 2012 · 12 revisions
  • Messaging API :

This API contains classes to define HTTP messages and exchange records (See https://github.com/easysoa/EasySOA/tree/master/easysoa-registry/easysoa-registry-api/easysoa-registry-api-messaging).

HTTP Message is used to build a java reprensentation of an HTTP message so it contains all the informations concerning the request and the response. Exchange record objects are used to store the HTTP messages.

Persistence layer for Exchange records is at the moment in the HTTP discovery proxy project (It will be moved in this API in the future). This layer work simply with an interface and has only one implementation class for file system persistance.

  • Templating engine

Correlation service : This service make an analysis of the request to define the most interessant fields. It is working with a correlation mechanism, comparing the request with the response.

TemplateBuilder : Builds a template from the field suggested by the correlation service and the exchange record. This template is mad with Velocity. Each suggested field is replaced in the request by a velocity expression (eg : $arg2.get("key"). Then, this 'custom' exchange is stored and can be used by the TemplateRenderer.

TemplateRenderer : Render a template by replacing the template expressions by the provided values. Then the result can be used by the tamplate executor.

TemplateExecutor : Execute the rendered template (send the request, using the utility class RequestForwarder) and returns the response.

  • Custom ProxyImplementationVelocity class (TODO : this is a hack, these work has to be included in Frascati distribution).

The proxyImplementationVelocity is modified to work with the TemplateRenderer. The velocity engine is configurated to work with an interface and a class instead of a servlet. See the HTTP Discovery proxy composite file, especially the code concerning the ProxyWSTemplate component (https://github.com/easysoa/EasySOA/blob/master/easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy/src/main/resources/httpDiscoveryProxy.composite)

  • Custom ServletImplementationVelocity class (TODO : this is a hack, these work has to be included in Frascati distribution).

This class has been modified to provide Easysoa custom features :

  • Returns the list of exchange stores when a request ending by "/target" is received. The list is returned as an HTML page.
  • Returns a WDSL corresponding to the records contained in an exchange store. The WSDL file is generated by loading and processing a pre-defined template.
  • Test to show how the classes work together :

It is available in the proxy-core-tests project (See https://github.com/easysoa/EasySOA/blob/master/easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-tests/src/test/java/org/openwide/easysoa/tests/ScenarioTest.java) and works with the HTTP Discovery proxy and the UI Scaffolding proxy. This test start a run, execute some REST requests, stop and store the run. Then a replay test is performed with the recorded exchanges, followed by the generation of requests/responses template for the test exchange store. When the template generation is done, the WSDL generation for the store is called and passed to the UI Scaffolding proxy to get an HTML form.

Clone this wiki locally