c# - Wcf 服务客户端不接收流消息

标签 c# asp.net-mvc wcf autofac

我遇到了奇怪的问题。我的 mvc 应用程序不想从 wcf 服务接收流。通过发送流一切都好!我的 Client.dll.config 文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="basicHttpStream" sendTimeout="00:05:00" messageEncoding="Mtom" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:61174/FileTransferService.svc"
                binding="basicHttpBinding" bindingConfiguration="basicHttpStream"
                contract="IFileTransferService" name="basicHttpStream" />
        </client>
    </system.serviceModel>
</configuration>

客户端收到此消息:“multipart/related; type="application/xop+xml";start="http://tempuri.org/0 ";boundary="uuid:6fc3add5-b28f-4842-a944-0bb6c79d05c6+id=6";start-info="text/xml""

我正在使用 Autofac 创建 channel :

builder
    .Register(c => new ChannelFactory<IFileTransferService>(
        new BasicHttpBinding(),
        new EndpointAddress("http://localhost:61174/FileTransferService.svc"))).InstancePerLifetimeScope();
builder.Register(c => c.Resolve<ChannelFactory<IFileTransferService>>().CreateChannel())
    .As<IFileTransferService>()
    .UseWcfSafeRelease();

最佳答案

我找到了决定! 问题出在 autofac 配置中。我需要设置绑定(bind)配置的名称。 正确的解决方案:

builder.Register(c => new ChannelFactory<IFileTransferService>(
     new BasicHttpBinding("basicHttpStream"),
     new EndpointAddress("http://localhost:61174/FileTransferService.svc"))).InstancePerLifetimeScope();
builder.Register(c => c.Resolve<ChannelFactory<IFileTransferService>>().CreateChannel())
    .As<IFileTransferService>()
    .UseWcfSafeRelease();

关于c# - Wcf 服务客户端不接收流消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34521545/

相关文章:

c# - 使用 C++ 或 C# 与端口通信?

c# - 频繁插入排序集合

c# - C# 中字符串数组的反序列化

C# 手动线程

asp.net-mvc - 仅针对 MVC 5 中的指定区域在自定义位置搜索 View 文件

wcf - WCF 中 MessageContract 的已知类型

.net - WCF IParameterInspector + IErrorHandler

c# - 传递两个模型查看

asp.net-mvc - ASP.NET MVC 5 中的路由

c# - 从 wcf c# 中的 URL 下载 zip 文件