0

I've been working on this issue for over a week now.

I've made much progress, however I've come to a problem which I'm unable to track or debug.

I'm developing in VS 2015 .NET Framework 4 on a Windows 8.1 machine.

The web service is being hosted in IIS 8 on a Windows Server 2012 machine on the same domain as my development environment.

I am able to make a call to another web service using a net.tcp endpoint and get a return successfully.

I believe IIS is setup correctly to host web service with the msmq endpoint, however the web service does not create the message queue nor does it create the message queue when running on my dev machine.

I don't know how to identify what would be the cause.

When I run the client application which dynamically creates a message queue for the web service to talk back to, it does create the message queue but the client is running as a console application.

Web Service

    [AuthenticationBehavior]
    public class LeaseService : ILeasesService
    {               
        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void SaveLease(ILease lease)
        {
        }

        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void InsertLeaseEntries(ILeaseEntry[] entries)
        {                
        }
    }
}

Web Service Host

    class Program
    {
        private static WebServiceHost _host;

        static void Main(string[] args)
        {
            var queue = @".\private$\ServerLeasesQueue";

            if (!MessageQueue.Exists(queue)) MessageQueue.Create(queue, true);

            _host = new WebServiceHost(typeof (LeaseService),
                new Uri(@"http://localhost:8080/LeaseService"));

            _host.Description.Name = "Culbreath.Leases.LeaseService";

            _host.Description.Behaviors.Add(new ServiceMetadataBehavior
            {
                HttpGetEnabled = true,
                HttpGetUrl = new Uri(@"http://localhost:8080/LeaseService")
            });

            var netMsmqBinding = new NetMsmqBinding(NetMsmqSecurityMode.Transport);
            netMsmqBinding.Security.Transport.MsmqProtectionLevel = ProtectionLevel.None;
            netMsmqBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;

            _host.AddServiceEndpoint(
                typeof(ILeasesService),
                netMsmqBinding,
                new Uri(@"net.msmq://localhost/private/ServerLeasesQueue"));

            _host.Open();
        }
    }
3
  • Can you clarify: Are you trying to expose a service over netMsmqBinding hosted in IIS? Why is your "web service host" a console app? What does this mean: When I run the client which dynamically creates a message queue for the web service to talk back to ? The service operations exposed all return void; there are no return types therefore there will be no "talking back". Jun 5, 2015 at 16:32
  • Also your code sample is too long. Please remove everything which is not relevant to the question Jun 5, 2015 at 16:32
  • @TomRedfern The web service is hosted in IIS on the windows 2012 server machine. The client is a console application. The client sends a message to the web service but the message is not received because the web service has not created a message queue. Jun 5, 2015 at 16:42

1 Answer 1

1

So through much hard searching, I found the problem. The name of the message queue must be the same as of the service file name, including the .svc.

var queue = @".\private$\LeaseService.svc";
if (!MessageQueue.Exists(queue)) MessageQueue.Create(queue, true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.