I struggled with this problem for several days, and I just can't figure out how to do this.
I have a simple WCF web service hosted on IIS and Windows Server 2008 R2. The web service implementation is as follows:
var completionResult = new CompletionResult(); var updateTextMessage = new UpdateText { TextTemplateId = textTemplateId, Text = text }; var asyncResult = Global.Bus.Send(updateTextMessage).Register(x => completionResult = x.AsyncState as CompletionResult, null); asyncResult.AsyncWaitHandle.WaitOne(10000); if (completionResult.Messages != null && completionResult.Messages.Length > 0) { return ((UpdateTextResponse)completionResult.Messages[0]).ImageData; } return string.Empty;
I know that trying to use NSB synchronously is considered a bad design, but I'm just experimenting, and I'd really like it to work. Therefore, the problem is that the message is successfully sent to the remote endpoint, and the message is processed successfully, but the response message is simply lost on the air when the remote endpoint does Bus.Reply. I am using the latest version of NSB, and it is strange that this works fine on my Windows 7 development machine. I made sure that the active directory is disabled on both machines. I also ran Wireshark on the receiving endpoint, and I'm sure that I see the incoming message in the packet data. Something does not seem to be alive with IIS. I also switched the registration threshold to DEBUG for both endpoints, and nothing unusual happens. The sending endpoint says the usual "sending messages to ..." Here is the code in my Application_Startup for the web component:
Bus = NServiceBus.Configure.WithWeb() .Log4Net() .DefaultBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(false) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .CreateBus() .Start();
Here are the configurations for the endpoints:
IIS Config (this side is not getting the response) <MsmqTransportConfig InputQueue="Web.InputQueue" ErrorQueue="Web.ErrorQueue" MaxRetries="5" NumberOfWorkerThreads="1"/> <UnicastBusConfig> <MessageEndpointMappings> <add Messages="Messages" Endpoint="Node.Distributor.DataInputQueue"/> </MessageEndpointMappings> </UnicastBusConfig> --------------------------------------------------------------- Endpoint which does the reply <MsmqTransportConfig ErrorQueue="Node.ErrorQueue" InputQueue="Node.InputQueue" MaxRetries="5" NumberOfWorkerThreads="1"/> <UnicastBusConfig DistributorControlAddress="Node.Distributor.ControlInputQueue" DistributorDataAddress="Node.Distributor.DataInputQueue" />
I also created two standalone NServiceBusHost applications to test communications, and it worked successfully. I also hardcoded the return address and replaced .Reply with .Send, but specifying the actual destination and it still doesn't work. So again, this is due to IIS. Any help would be greatly appreciated!
source share