使用带流传输模式的basichttpBinding在WCF中出错错误请求

时间:2014-03-05 09:50:30

标签: c# wcf

我有一个消耗我的WCF服务的问题,首先我尝试使用我的wcf而不添加服务引用,并且我使用channelfactory消耗它当我使用basichttpbinding和transfermode的缓冲它工作正常,但当我使用流式传输作为transfermode它给出错误错误请求

以下是我致电服务的地方,请提前致谢

public static BasicHttpBinding basicHttpBinding()
    {
        BasicHttpBinding BasicHttpBinding_IService1 = new BasicHttpBinding();
        BasicHttpBinding_IService1.CloseTimeout = TimeSpan.Parse("00:01:00");
        BasicHttpBinding_IService1.OpenTimeout = TimeSpan.Parse("00:01:00");
        BasicHttpBinding_IService1.ReceiveTimeout = TimeSpan.Parse("00:10:00");
        BasicHttpBinding_IService1.SendTimeout = TimeSpan.Parse("00:01:00");
        BasicHttpBinding_IService1.AllowCookies = false;
        BasicHttpBinding_IService1.BypassProxyOnLocal = false;
        BasicHttpBinding_IService1.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        BasicHttpBinding_IService1.MaxBufferSize = 2147483646;
        BasicHttpBinding_IService1.MaxBufferPoolSize = 524288;
        BasicHttpBinding_IService1.MaxReceivedMessageSize = 2147483646;
        BasicHttpBinding_IService1.MessageEncoding = WSMessageEncoding.Text;
        BasicHttpBinding_IService1.UseDefaultWebProxy = true;
        BasicHttpBinding_IService1.TextEncoding = UTF8Encoding.UTF8;
        BasicHttpBinding_IService1.TransferMode = TransferMode.Streamed;


        return BasicHttpBinding_IService1;
    }

    public static EndpointAddress endPointAddress()
    {
        EndpointAddress endpointAddress = new   EndpointAddress("http://localhost:5409/IService.svc");

        return endpointAddress;
    }


private void button1_Click(object sender, EventArgs e)

    {
        ChannelFactory<IService> myChannelFactory = null;
        myChannelFactory = new ChannelFactory<IService>(basicHttpBinding(), endPointAddress());
        IService client =  myChannelFactory.CreateChannel();
        MessageBox.Show(client.GetData(1));
    }

1 个答案:

答案 0 :(得分:0)

ASP.NET开发服务器不支持TransferMode Streamed

使用IIS或自托管WCF服务来绕过它。