我正在使用带有自定义绑定的WCF服务,我设置了gzip以减少结果的长度。最近我们迁移到.NET Core,在核心项目中调用我的方法之后我得到了这个错误
接收到
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 :(得分:3)
这是.net核心问题,我通过安装Visual Studio 2017修复了这个问题。你应该卸载它然后安装最新版本的net core。目前是1.1.2
答案 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>