2017-05-10 144 views
2

我正在使用自定義綁定的WCF服務,我設置了gzip以減少我的結果的長度。最近我們遷移到.NET Core,並且在我的核心項目中調用我的方法後,出現此錯誤呼叫WCF服務窗體Dotnet核心

接收到對http://www.???.com:96/TicketCache.svc/mex的HTTP響應時發生錯誤。這可能是由於服務端點綁定不使用HTTP協議。這也可能是由於HTTP請求上下文被服務器中止(可能是由於服務關閉)。查看服務器日誌獲取更多詳細信

後,我改變了我的配置在WCF並將其設置爲基本約束,它的工作

我搜索了很多和測試不同的方式很好,但我不能回答

BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); 

binaryMessageEncodingBindingElement.CompressionFormat = CompressionFormat.GZip; 

HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement(); 
httpTransportBindingElement.MaxReceivedMessageSize = 65536000; 
httpTransportBindingElement.MaxBufferSize = 65536000; 

CustomBinding customBinding = null; 
customBinding = new CustomBinding(new BindingElement[] { binaryMessageEncodingBindingElement, httpTransportBindingElement }); 
customBinding.OpenTimeout = TimeSpan.FromMinutes(10); 
customBinding.CloseTimeout = TimeSpan.FromMinutes(10); 
customBinding.ReceiveTimeout = TimeSpan.FromMinutes(20); 
customBinding.SendTimeout = TimeSpan.FromMinutes(10); 
customBinding.CreateBindingElements(); 

var factory = new ChannelFactory<customBinding, new EndpointAddress("http://www.???.com:96/TicketCache.svc/mex")); 

如何我可以解決這個問題嗎?

+0

是服務啓動和運行,並且防火牆的訪問授權? – ColinM

+0

我允許在防火牆的服務,並打開它 –

回答

3

這是.net核心問題,我通過安裝visual studio 2017解決了這個問題。你應該卸載它,然後安裝最新版本的net core。目前是1.1.2

+0

它爲我工作,但你有什麼辦法改變.NET的核心版本? –

+0

是的,這是由於「數據合同」問題而發生的錯誤。但我不知道它是否會用另一種解決方案修復 – Houtan

+0

我在VS2017和.net核心1.1.1的其他系統上測試它,它工作,我很困惑 –

0

添加如下代碼下面的web.config

<behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehaviour"> 
     <useRequestHeadersForMetadataAddress> 
     <defaultPorts> <!— Use your own port numbers —> 
      <add scheme="http" port="enter your web service port :8088" /> 
     </defaultPorts> 
     </useRequestHeadersForMetadataAddress> 
     </behavior> 
    </serviceBehaviors> 

+0

我的問題是關於.netCore項目,它與.netframwork項目及其與我的web服務無關 –