Wcf服务客户端没有';t接收流消息

本文关键字:消息 客户端 服务 Wcf | 更新日期: 2023-09-27 18:28:23

我遇到了一个奇怪的问题。我的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";border="uuid:6fc3add5-b28f-4842-a944-0bb6c79d05c6+id=6";开始信息="text/xml"

我正在使用Autofac创建通道:

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();

Wcf服务客户端没有';t接收流消息

我找到了决定!问题出在自动交流配置中。我需要设置绑定配置的名称。正确的解决方案:

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();