Skip to content

Service Message Level Processing

JGuillemotte edited this page Mar 8, 2012 · 19 revisions

Service message level processing

Two main functions :

  • Data extraction to have informations about the protocol (SOAP, HTTP ...) and to get the message content.
  • Setup of this extraction and on it transversal services, such as making it compatible with a previous version, security, message replaying ...

Three Methods / Solutions

  • Proxy wrapper : The Http discovery proxy act as an HTTP proxy. TODO tunnel != http proxy, ref monit

  • FraSCAti intents : An intent can be plugged on a SCA component.

  • CXF interceptors / JAXWS handlers : Using CXF Provider (server) / Dispatcher (client) api. With this API, we could create dynamic HTTP clients / servers for REST and especially for SOAP protocols.

Proxy Wrapper

HTTP Proxy

The role of the HTTP discovery proxy is to listen HTTP exchange and to record them for different uses. First use is to register them as services, applications, api's in the EasySOA Nuxeo registry. Second use is to store them for replay, template and assertion features.

See HTTP Discovery proxy sources at : https://github.com/easysoa/EasySOA/tree/master/easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy

Tunnel

TODO tunnel != http proxy, ref monit

FraSCAti intents

Here is an example of intent generating UML sequence diagrams from SCA components at runtime : http://websvn.ow2.org/listing.php?repname=frascati&path=%2Ftrunk%2Ffrascati%2Fintents%2Fuml-sequence-diagram%2F&#

Benefit and drawbacks : can be simply added in an SCA component but the usage of intent it can be difficult to have access and to modify protocol informations. In this cas, the use of intent is limited to business logic.

CXF interceptors / JAXWS handlers

The Client (JAXWS Dispatch) :

Easier dynamic client, works on payload (SOAP body) or whole message, can work on different models, ex. for cxf : Source (DOM / SAX / Stream), JAXB (SOAP only), SOAPMessage, DataSource (mime ; http only).

For general informations about dispatch API : http://cxf.apache.org/docs/jax-ws-dispatch-api.html See the following link for developping a client : http://cxf.apache.org/docs/how-do-i-develop-a-client.html

Here is a example on how to work with an XML SOAP message : ex. soap message : @ServiceMode(value=javax.xml.ws.Service.Mode.MESSAGE) See https://blogs.oracle.com/artf/entry/operating_at_the_xml_message

The server (JAXWS Provider) :

Can work on same models. See http://cxf.apache.org/docs/provider-services.html though JAXB can be done manually within payload mode (i.e. soap body only), see http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java?view=markup

Working With REST :

Here is an example in rest with CXF : http://cxf.apache.org/docs/rest-with-jax-ws-provider-and-dispatch.html

xpath provider from xpath expression produces a filled class instance http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XPathProviderTest.java?view=markup

About security :

CXF STS provider framework : SPI for implementing or integrating its own STS server in CXF See http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java?view=markup

CXF SOAP or REST gives access to HTTP headers and much more in its CXF Message with its own attributes, available using JAXWS WebServiceContext some are standard, others specific ex. Map Message.PROTOCOL_HEADERS, see all at : http://www.docjar.com/html/api/org/apache/cxf/message/Message.java.html and http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/restful_dispatch/src/main/java/demo/restful/server/RestSourcePayloadProvider.java?view=markup

Sample code to obtain header informations. An injected WebServiceContext is used here :

import org.apache.cxf.message.Message;

@Resource

protected WebServiceContext wsContext;

String path = (String)mc.get(Message.PATH_INFO);

String query = (String)mc.get(Message.QUERY_STRING);

String httpMethod = (String)mc.get(Message.HTTP_REQUEST_METHOD);

Generic HTTP probe architecture redux :

  • frontend : HTTP / jetty (no choice here)
  • emitter / forwarder / sender (abstracted in its own SCA service) : could use a CXF REST or SOAP dynamic client, whose message uses HTTP & SOAP headers & content custom mapped from read ones ; though not better than now at all.

Specific / business probe architecture redux :

  • extract HTTP headers from CXF Message (available from JAXWS WebServiceContext). TODO are all available ??? (otherwise CXF interceptor required)
  • extract SOAP headers either from CXF Message, or using custom code (in Intent or wrapper), or more elegantly using a dedicated service wrapper proxy in JAXWS Provider Message mode, or (for ex. unsupported SOAP 2.0) in DataSource mode using custom parsing
  • do both either in generic Intent, or in proxy wrapper, OR CXF interceptor
  • extract business attributes either from business Intent (scripted in Light / FStudio), or using a dedicated service wrapper proxy in JAXWS Provider / Message / DOMSource and configured (injected properties or service) xpath expressions, or (for ex. unsupported content or JSON if not supported ??) in DataSource mode using custom parsing ; OR using custom CXF interceptor
  • emitter / forwarder / sender (abstracted in its own SCA service) : could use a CXF REST or SOAP dynamic client, whose message uses HTTP & SOAP headers & content taken easily from CXF Message ; though not much better than now.

EasySOA example

A simple EasySOA example of provider/dispatcher API in a test using SOAP. See https://github.com/easysoa/EasySOA/blob/2983e8869e6d5307637facfdfe4f5f15c17a1b2b/easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy/src/test/java/org/easysoa/cxf/CxfProviderDispatcherTest.java

At the moment, there is a problem using JAX-WS in FraSCAti : A lot of JAX-WS annotation are not fully supported by FraSCAti, most of the time simply ignored (see https://github.com/easysoa/EasySOA/issues/23).

JAX-WS Handlers

JAXWS @HandlerChain annotation allows to configure JAXWS Handlers, which in CXF are CXF interceptors. See this tutorial : http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial

TODO Q FraSCAti CXF's implementation of the JAX-WS Handlers is based on its native interceptors http://soasidewalk.blogspot.com/2008/02/apache-cxf-and-soap-headers.html ?? and WS-* headers ??

Clone this wiki locally