[英]WCF REST Service - passing additional parameters not in the contract
I'm about to set up a RESTful web service in WCF. 我将在WCF中设置RESTful Web服务。
My question is how can you create a Service Host using a Service contact as the basis of the request, but also pass in additional parameters in the querystring that are not declared in the contact. 我的问题是如何使用服务联系人作为请求的基础来创建服务主机,又如何在查询字符串中传递未在联系人中声明的其他参数。
Can you access the headers to access the querystring from the service implementation? 您可以访问标头以从服务实现中访问查询字符串吗? Is there a way of intercepting the request and compiling a Dictionary for the additional querystring params, and then pass this in to the operation? 有没有办法拦截请求并为其他查询字符串参数编译一个Dictionary,然后将其传递给操作?
Here's a sample ServiceContact I found. 这是我找到的样本ServiceContact。
[ServiceContract]
public interface ITest
{
[OperationContract]
[WebGet(UriTemplate = "Test?format=XML&code={code}", ResponseFormat = WebMessageFormat.Xml)]
string TestXml(string code);
}
Taking this example I'd either need to be able to access the querystring params from the TestXml method or pass an additional dictionary/generic object as a parameter. 以这个例子为例,我要么需要能够从TestXml方法访问querystring参数,要么需要传递一个附加的字典/通用对象作为参数。
Thanks in advance, 提前致谢,
Sam 山姆
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.