简体   繁体   中英

I'm trying to setup a WCF Service that is called via the MsmqIntegrationBinding and I'm getting an error

System.InvalidOperationException: The MsmqIntegrationBinding validation failed. The service cannot be started. The MsmqIntegrationBinding binding does not support the method signature for the service operation.

I'm working from the following sample Here The only setting I've changed is I need to use the ActiveX Serialization Format.

Interface

namespace MQTest
{
    //MSMQIntegrationBinding
    [ServiceContract]
    public interface IMQService
    {
        [OperationContract(IsOneWay = true, Action = "*")]
        void GetData(string value);
    }
}

Service

 public class MQService : IMQService
    {
        public static void Main()
        {
            // Get base address from appsettings in configuration.
            Uri baseAddress = new Uri("http://localhost:8000/Test/Service");

            // Create a ServiceHost for the CalculatorService type and provide the base address.
            using (ServiceHost serviceHost = new ServiceHost(typeof (IMQService), baseAddress))
            {
                // Open the ServiceHostBase to create listeners and start listening for messages.
                serviceHost.Open();

                // The service can now be accessed.
                Console.WriteLine("The service is ready.");
                Console.WriteLine("The service is running in the following account: {0}",
                                  WindowsIdentity.GetCurrent().Name);
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();

                // Close the ServiceHostBase to shutdown the service.
                serviceHost.Close();
            }
        }
        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void GetData(string value)
        {
            Console.WriteLine(value);
        }
    }

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="MQTest.MQService">
                <endpoint address="msmq.formatname:DIRECT=OS:.\private$\outbound_adt_a08"
                                        binding="msmqIntegrationBinding"
                          bindingConfiguration="OrderProcessorBinding"
                          contract="MQTest.IMQService">
                </endpoint>
            </service>
        </services>

        <bindings>
            <msmqIntegrationBinding>
                <binding name="OrderProcessorBinding" serializationFormat="ActiveX">
                    <security mode="None" />
                </binding>
            </msmqIntegrationBinding>
        </bindings>
    </system.serviceModel >
</configuration>

It looks like the interface must accept an MsmqMessage

I changed my interface and it's working now. Maybe this will help someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM