I came across this blog last week, detailing a problem he is facing with WSE 2.0
Now I that realize who he is (Hello Fai
), I peep into his project to see how I could help. Fai, incidentally, is the Academic DE for MSFT Malaysia and I met him in MS Tech.ED 2004 Asia in Msia.
Since I cannot comment on this blog (since theSpoke doesnt allow it
and I dont intend to keep another account), I will comment on his problem here.
I reproduce Fai's blog snippets here.
SoapSender & SoapReceiver
I've been mucking around with WSE 2.0 Messaging, now moving on to SoapSender and SoapReceiver. I noticed a potential problem when I have a class that extends the SoapReceiver class, and within the Receive() method, it also sends out a SoapEnvelope via the SoapSender.Send() method. The problem only arises when I use a real transport protocol, i.e., TCP, but not when I'm using the in-proc transport. I've tried all sort of ways, including transfering the SoapSender code away from the Receive() method to a method in another class. But it still doesn't work.
The behavior of my current Receive() method almost seems like it is acting like a SOAP router. This is because it receives a SoapEnvelope, sends out another SoapEnvelope albeit doing some computation and returning a totally different SoapEnvelope.
Then I discovered the IsIntermediary property of the Pipeline class from this blog. According to the WSE 2.0 Class Reference, this property gets or sets a value indicating whether the pipeline is running within a SOAP router. Fair enough, and I implemented the following code:
// send response SOAP message
SoapEnvelope env = new SoapEnvelope();
env.Context.Addressing.Action = e.Context.Addressing.Action;
env.Context.Addressing.Destination = e.Context.Addressing.ReplyTo;
env.SetBodyObject(resp);
Pipeline pipe = new Pipeline();
pipe.IsIntermediary = false;
pipe.ProcessOutputMessage(env);
SoapSender responseSender = new SoapSender(env.Context.Addressing.Destination);
responseSender.Pipeline = pipe;
responseSender.Destination = env.Context.Addressing.Destination;
responseSender.Send(env);
I've also tried move the MathResponseReceiver class to a separate project so that it can be started separately. Still to no avail. According to another blog I read, WSE 2.0 is smart enough to know if there are two receivers classes within a single application domain, and both are communicating with each other using an actual network protocol like TCP or HTTP, it will detect that and switch it in-process instead.
But still it doesn't work! I appreciate if anyone out there could help me fix this. Could it be a bug in WSE 2.0?
Steve talks about pipelines and routing in his blog above. However, I dont think the pipeline.IsIntermediary helps you in this case because you really never did subject your message through a routing pipeline. Therefore, it doesnt address or solve your problem at all.
The problem (after looking through your codes and running SOAP Trace Diagnostics) and you are going to hate me for this, is just a programmatic syntax error
env.Context.Addressing.Destination = e.Context.Addressing.ReplyTo.Address.Value;
What you missed out was actually pass in the address property of the ReplyTo class. This address property (which is inherited from an EPR) will get you the address of the destination.
So, your final code snippet should simply look like this (without the pipelines class):
SoapSender responseSender = new SoapSender(e.Context.Addressing.ReplyTo.Address.Value);
SoapEnvelope env = new SoapEnvelope();
env.Context.Addressing.Action = e.Context.Addressing.Action;
env.SetBodyObject(resp);
responseSender.Send(env);
I hope this helps. Try it and let me know here if it works.