c# - 我正在尝试设置通过 MsmqIntegrationBinding 调用的 WCF 服务,但出现错误

标签 c# wcf msmq

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

我正在使用以下示例 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);
        }
    }

应用程序配置

<?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>

最佳答案

看起来接口(interface)必须接受 MsmqMessage

我更改了我的界面,现在可以使用了。 也许这会对其他人有所帮助。

关于c# - 我正在尝试设置通过 MsmqIntegrationBinding 调用的 WCF 服务,但出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5758815/

相关文章:

java - 将 XML 从 Java 发送到 MSMQ - bodyType 从 VT_EMPTY 到 VT_BSTR

javascript - 如何访问 angularJS 中服务工厂函数的返回值

c# - 在反序列化之前获取 WCF 消息正文

c# - 如何在客户端部署带有sql server数据库的应用程序

c# - 无法让 netTcpBinding 请求显示在 Fiddler 中

c# - Silverlight F# 库和 WCF

wcf - WCF MSMQ 4.0 中的中毒消息处理

msmq - 将邮件从死信队列移至传出队列MSMQ

c# - 如何使用MS interop excel检测c#中的合并单元格

C# 套接字多线程 Lambda