我正在尝试设置通过 MsmqIntegrationBinding 调用的 WCF 服务,但收到错误

发布于 2024-11-03 11:18:45 字数 2825 浏览 1 评论 0原文

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

我正在使用以下示例此处 我更改的唯一设置是我需要使用 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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖不如嘢 2024-11-10 11:18:45

看起来接口必须接受 MsmqMessage

我更改了接口并且现在可以工作了。
也许这会帮助别人。

It looks like the interface must accept an MsmqMessage

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文