[英]How to disable Expect:100-Continue when using WCF in Windows Store App
在Windows Store App中使用WCF与WebService通信时,我需要摆脱HTTP消息中的Expect: 100-Continue
标头。 我找到了很多解决方案,但在Windows 8中没有一个是可能的:
ServicePoint.Expect100Continue = false;
在Store App中不再存在(No SericePoint
或ServicePointManager
类), web.config
文件中的配置,因为它在Store App中不存在, HttpClient
更改标志,但在使用WCF时我无法访问它, IClientMessageInspector
处理消息头,但是稍后在较高层中添加了默认的HTTP头,因此我的更改将是ovverriden。 有没有人有任何其他想法?
有两种方法可以解决这个问题。
您可以在app.config或web.config中设置expect100Continue =“false”,但这将是全局的 。 如果某些外部服务更喜欢使用标头expect100Continue,这可能是一个问题。 这是如何做:
<system.net>
<settings>
<servicePointManager expect100Continue="false"/>
</settings>
</system.net>
或者您可以在特定端点的代码中执行此操作,如下所示:
System.Net.ServicePoint servicePoint =
System.Net.ServicePointManager.FindServicePoint(myWcfService.Endpoint.Address.Uri);
servicePoint.Expect100Continue = false;
// now execute some service operation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.