1 Reply Latest reply on Nov 9, 2017 11:37 AM by Bernard H

    JBoss ESB and AS2 support

    Radek Jakubowski Newbie

      Hi!

      Does JBoss ESB supports AS2? If not do you have any idea how to make it send/receive AS2 messages?

        • 1. Re: JBoss ESB and AS2 support
          Bernard H Newbie

          I have just completed an AS2 connector integration on JBoss with CAMEL and Spring. Works fine with sync and async MDN or no MDN, with and without encryption...all options available.

          The stack is as follows:

          * JBoss EAP7

          * Spring framework 4.2 where the org.springframework.web.servlet.DispatcherServlet is used only for a connector Admin REST API in Spring MVC, and the org.springframework.web.context.ContextLoaderListener actually loads a CAMEL context for connector operations in proper. We also take advantage from org.springframework.jmx.export.MBeanExporter for Bean exposure via JMX.

          * CAMEL 2.16, using the http servlet CAMEL component for inbound traffic. Outbound traffic is managed by an HTTP client embedded in /n Software libraries (see just next)

          * /n Software AS2 libraries = commercial licence, the AS2 EDI Integrator product, fair price with quite good support

           

          We have separated the IN and OUT flows in separate WAR deployments. The IN flow listens on distinct URLs for AS2 data messages and async MDNs respectively. The OUT flow HTTP sessions are directly handled by /n Software libraries (embedded HTTP client).

           

          OUTLINE:

           

          First, get acquainted with /n Software product documentation and examples and run them. I assume too that you have expertise in CAMEL and Spring..

           

          On the IN side,  a CAMEL route will catch incoming EDI Data or async MDNs. Start a CAMEL context containing a route with a from() statement (XML DSL or Java DSL) and a CAMEL URI like

          "servlet://<your URL path element that will follow the app deployment URL context>?servletName=<your servlet name as declared in the web.xml>&httpBindingRef=fixedAsxBinding"

           

          Side Note: The last URI option "httpBindingRef=fixedAsxBinding" make reference to a custom fix in the default CAMEL HTTP Binding linked to the fact that a HTTP request comes as a stream object that you can only read once and I was unable to take advantage of relevant CAMEL options.... so copy the original HTTPBinding source, run sessions in debug mode, and you'll see...I suspect that this is fixed in JBoss ESB / Fuse where CAMEL has been repacked by Red Hat, or else in later CAMEL versions. You shall not attempt to push another CAMEL version in JUSE ESB. In EAP7, CAMEL is not embedded and you have to pack it in your WAR or make CAMEL available as custom EAP Modules.

           

          The raw HttpRequest's are then captured through (where exchange is the CAMEL Exchange object):

          javax.servlet.http.HttpServletRequest request = ( (org.apache.camel.http.common.HttpMessage) exchange.getIn() ).getRequest();

          and then digested by a inedi.As2Receiver bean from the /n Software libs, simply as follows: as2receiver.readRequest(request); note that you shall instantiate the as2receiver bean, call readRequest(...), then set a number of properties at least regarding keystore and certificates before calling 'as2receiver.processRequest();'

           

          Onwards, you manipulate the request and notably decide which MDN sync or async or none is required with help of 'as2receiver.getMDNTo()' and 'as2receiver.getReceiptDeliveryOption()' :

          - you can return an async MDN with 'as2receiver.sendAsyncMDN(...)' - this will use the embedded HTTP client to open a session back to the remote party

          - else, you must return a sync MDN in the HTTP response payload under control by CAMEL this time, therefore notably use 'inedi.MDNReceipt mdn = as2receiver.getMDNReceipt();' and 'exchange.getIn().setBody(mdn.getContent());'

          - else the async MDN was returned as above, or else no MDN was at all required, and you still need to return an HTTP 200 OK response with CAMEL, for instance with 'exchange.getIn().setBody("");' and 'exchange.getIn().setHeader("CamelHttpResponseCode", new Integer(200));'

           

          On the OUT side, this is simpler. The As2Sender bean from /n Software does all the work of opening an HTTP session and handling the sync MDN response or simply the HTTP 200 OK response when requesting an async MDN or no MDN. Of course, after you instantiate the as2sender bean you shall set a number of properties linked to keystore and certificates, encryption and signature requests, MDN request and sync or asyn mode, etc. Once all parameters are set, as2sender.post(); does all the job. Sample code is available in the /n Software distribution.