Architectural question: Service Aware endpoints
viniciuscarvalho Dec 28, 2007 4:36 PMHi again :)
I'm facing an dilemma here, and I hope someone from the ESB team could help me out.
I have a previous experience with ESBs (Websphere ESB, aka WESB), which in my own opinion, of use in a project (it sucks, expensive, buggy, not flexible... anyway)
One thing that I found a good design though, is the way it exposes the bus to the world, we have imports and exports. It's easy to have an import and have your bus invoked using JMS or SOAP, and we manage the request/response message flow.
Well, we are using Jboss ESB to have a service available through a different kind of protocols (so far JMS/SOAP and soon FTP)
My WebService interface has only OneWay operations, so, I do not put anything on the response.
Now, since the SOAPProcessor is an action, it takes the response from the WS and put on the body of the message, overriding what I've done before.
Here's a snippet of my WS:
public Source invoke(Source source) { Message message = SOAPProcessor.getMessage(); try{ Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); StringWriter writer = new StringWriter(); StreamResult streamResult = new StreamResult(writer); transformer.transform(source, streamResult); message.getBody().add(writer.toString()); }catch (Exception e) { e.printStackTrace(); } return getResponseSource(); }
At this point my body contains the payload of the operation, this should be sent to the bus and other actions take place.
The problem is that the SOAPProcessor overrides it and set the response of my service (I have not even started the flow of events that will build my response) to the default body location.
Since I'm using one-way, all I need to return to my client at this point is an empty soap envelope.
I was reading the programmers guide, and I do know that one should be careful when dealing with the default location of the body, but, summing all my story into one question:
Wouldn't be a better choice, if the exposed Service should not be considered just another action on the flow, but just a listener that deliveries messages to the bus?
If someone understand my bad-confusing English, would you mind to give me a hand here?