添加查询字符串参数来接受流WCF服务操作 [英] Adding querystring parameters to a WCF service operation that accepts Stream

查看:170
本文介绍了添加查询字符串参数来接受流WCF服务操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法来配置的WebHttpBinding WCF服务接受多个的查询字符串的参数,用参数是请求的身体?

Is there any way to configure a webHttpBinding WCF service to accept multiple querystring arguments, with a Stream argument being the body of the request?

我想这样做没有从操作签名省去查询字符串参数,并从的OperationContext直接访问它们。

I'd like to do this without omitting the querystring arguments from the operation signature and accessing them from the OperationContext directly.

UriTemplate 似乎是显而易见的选择,但是这不仅导致AddressFilter不匹配的异常被抛出。

UriTemplate seemed like the obvious choice, but that only results in AddressFilter mismatch exceptions being thrown.

移动参数传递给MessageContract wtih的MessageHeader属性在所有非流场,以避免流可以是唯一的参数的错误,会导致的MessageHeader属性不支持的WebHttpBinding一个错误。

Moving the arguments to a MessageContract wtih MessageHeader attributes on all non-Stream fields, in order to avoid the "Stream can be the only argument" error, causes an error that MessageHeader attributes aren't supported with webHttpBinding.

这是流不支持MessageContracts的WebScriptEnablingBehavior反正在MessageContract只留下流参数通知我。

Leaving only the Stream argument on the MessageContract informs me that Streams aren't supported in MessageContracts for WebScriptEnablingBehavior anyway.

有什么想法?

推荐答案

该解决方案是:

  1. 标记与 [WebInvoke] 属性,它有一个方法=POST和操作 UriTemplate ,其中包括在查询字符串
  2. 设置端点的结合的WebHttpBinding
  3. 添加< webHttp /> 到您的端点的behaviorConfiguration
  4. 设置 transferMode =流媒体您端点的绑定配置
  1. Mark the operation with a [WebInvoke] attribute that has a Method="POST" and a UriTemplate that includes your non-stream arguments in the querystring
  2. Set the endpoint's binding to webHttpBinding
  3. Add <webHttp/> to your endpoint's behaviorConfiguration
  4. Set transferMode="Streamed" on your endpoint's binding configuration

有些事情需要注意的:

  • wsHttpEndPoint和basicHttpEndPoint不支持流,非流参数的组合。如果您需要SOAP +的WebHttpBinding,你需要使用两个服务接口和两个端点(尽管具体的实施可以共享)
  • 的WSDL生成器不支持,要么,所以访问帮助页面(调用该服务将仍然被罚款,虽然)当你需要禁用MEX上webHttp端点或将引发异常

这篇关于添加查询字符串参数来接受流WCF服务操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆