【问题标题】:I'm trying to setup a WCF Service that is called via the MsmqIntegrationBinding and I'm getting an error我正在尝试设置通过 MsmqIntegrationBinding 调用的 WCF 服务,但出现错误
【发布时间】:2011-08-11 03:46:04
【问题描述】:

System.InvalidOperationException:MsmqIntegrationBinding 验证失败。服务无法启动。 MsmqIntegrationBinding 绑定不支持服务操作的方法签名。

我正在使用以下示例 Here 我更改的唯一设置是我需要使用 ActiveX 序列化格式。

界面

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

服务

 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>

【问题讨论】:

    标签: c# wcf msmq


    【解决方案1】:

    看起来接口必须接受一个 MsmqMessage

    我改变了我的界面,它现在可以工作了。 也许这会对其他人有所帮助。

    【讨论】:

    • 啊,我正在写一个答案 :) 仅供参考,当使用 Accept="*" OperationContract 时,该方法必须只接受一个 Message 参数(在这种情况下,是一个 MsmqMessage&lt;T&gt;)。
    猜你喜欢
    • 2012-04-30
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-23
    相关资源
    最近更新 更多