2014-03-05 66 views
1

Im在使用我的WCF服務時出現問題,首先嚐試在不添加服務引用的情況下使用我的wcf,並且使用channelfactory來使用它時使用basichttpbinding和transfermode緩衝它工作正常,但是當我使用流作爲transfermode它給錯誤錯誤請求錯誤WCF中使用basichttpBinding和流式傳輸模式的錯誤請求

此處,我打電話給我的服務請看看在此先感謝

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)); 
    } 
+0

根據您的代碼,您使用的是緩衝而不是流式傳輸模式。也許這是有效的「好」代碼。如果我遇到了這個問題,我會確保主機和客戶端軟件對您使用的模式達成一致。我曾嘗試過流式傳輸,雖然它在服務器內存使用情況良好,但在$ $$中正確運行卻是一種痛苦。除非你的項目存在嚴重的內存限制,否則不要考慮流媒體。 – Brian

+0

感謝您的回覆,我需要使用流式傳輸進行大文件下載 – Angelo

+0

您是否嘗試過查看[WCF診斷](http://msdn.microsoft.com/zh-cn/library/ms733025(v = vs.110) ).aspx)的更多細節? –

回答

0

StreamedTransferMode不是由ASP支持。 NET開發服務器。

使用IIS或自我託管WCF服務來避開它。

+0

我爲它使用IIS – Angelo

相關問題