繁体   English   中英

如何在Windows应用商店应用中使用WCF时禁用Expect:100-Continue

[英]How to disable Expect:100-Continue when using WCF in Windows Store App

在Windows Store App中使用WCF与WebService通信时,我需要摆脱HTTP消息中的Expect: 100-Continue标头。 我找到了很多解决方案,但在Windows 8中没有一个是可能的:

  1. ServicePoint.Expect100Continue = false; 在Store App中不再存在(No SericePointServicePointManager类),
  2. 我无法更改web.config文件中的配置,因为它在Store App中不存在,
  3. 可以在HttpClient更改标志,但在使用WCF时我无法访问它,
  4. 我尝试使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM