In my previous posts about Indigo messaging making use of channels;
A slightly
different "hello world" for Indigo
Layers of
Indigo
Indigo-
Moving on from IInputChannel to IRequestChannel
I went with the default encoding of the messages that were sent on the wire
whilst in this posting
Layers of Indigo
I mentioned that it's possible to plug in an encoder (a class deriving from
MessageEncoder with primary methods looking to be ReadMessage,
WriteMessage) in order to change the nature of the message on the wire.
One way in which we can alter the encoder is to switch the
MessageEncoderFactory property on the HttpListenerFactory/HttpChannelFactory
before beginning to make use of it. The 3 supplied variants of
MessageEncoderFactory look to be BinaryMessageEncoderFactory,
TextMessageEncoderFactory, MtomMessageEncoderFactory.
The "client" side code of my sample now looks like this if I switch in the
BinaryMessageEncoderFactory;
static void Main(string[] args)
{
HttpChannelFactory factory = new
HttpChannelFactory();
factory.MessageEncoderFactory = new
BinaryMessageEncoderFactory();
factory.Open();
IOutputChannel channel =
factory.CreateChannel<IOutputChannel>(
"http://localhost:5050/simpleService");
channel.Open();
StringReader content = new StringReader("<hello>world</hello>");
XmlTextReader reader = new
XmlTextReader(content);
Message message =
Message.CreateMessage("urn:someAction",
reader);
channel.Send(message);
message.Close();
channel.Close();
factory.Close();
}
The "service" side would also need to be modified to use the same encoder in
order to continue to allow these 2 pieces to talk to each other.
Posted
Thu, Mar 31 2005 2:25 PM
by
mtaulty