jeljer te Wies wrote:
> The esb (as you probably know) should be able to handle multiple
> protocols (JSON, XML, SOAP).
> So it has a tcp socket and it gets a "request".
> 
> The problem is that I can't figure out how to check what protocol is
> used. (the only thing i can figure out is to just try to transform it
> with every known "protocol" until it doesn't return an error anymore.
> This is however not the most elegant solution.

This is an encapsulation issue.

If your messages are transported using HTTP then you have a 
"Content-Type:" header which says whether it's application/json or 
application/xml. And/or you can have different HTTP endpoint URLs for 
these different services (/foo.xml, /foo.json, /foo.soap or whatever)

I find it highly unlikely in a real ESB that the messages are squirted 
over a raw TCP socket as you describe. For example, you wouldn't be able 
to send multiple messages over the same connection, because the only way 
the endpoint would be able to determine that the message had finished 
would be waiting for the socket to close (*).

But even in that case you can have multiple endpoints, by listening on 
different TCP ports. So make your SOAP listener listen on one port, and 
your JSON one on a different port.

HTH,

Brian.

(*) Yes, I know stream parsers can tell when the closing tag is 
received. The closing tag could be followed by whitespace and/or 
comments. It would be a very strange system which allowed multiple XML 
roots to be sent one after the other. The nearest equivalent would be 
something like XMPP, but that has a single opening root tag followed by 
nested messages.
-- 
Posted via http://www.ruby-forum.com/.