使用WCF阅读http帖子 [英] Reading the http post using WCF
本文介绍了使用WCF阅读http帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我需要阅读发送到wcf服务的http帖子.
我需要创建一种服务来读取http帖子.
请帮我做那个
谢谢
Santhosh
Hi
I need to read the http post which is sent to my wcf service.
I need to create a service such a way that it reads the http post is posted.
Please help me to do that
Thanks
Santhosh
推荐答案
假设您具有这样的服务合同
Suppose you have service contract like this
[ServiceContract]
public interface ISampleService
{
[OperationContract]
[WebInvoke(UriTemplate = "invoke")]
void DoWork(Stream input);
}
您的html表单就像
And your html form is like
<form method="post" action="Service.svc/invoke">
<label for="firstName">First Name</label>: <input type="text" name="firstName" value="" />
<br /><br />
<label for="lastName">Last Name</label>: <input type="text" name="lastName" value="" />
<p><input type="submit" /></p>
</form>
然后您的运营合同将被执行
Then implementation of your operation contract will be
public void DoWork(Stream input)
{
StreamReader sr = new StreamReader(input);
string s = sr.ReadToEnd();
sr.Dispose();
NameValueCollection qs = HttpUtility.ParseQueryString(s);
string firstName = qs["firstName"];
string lastName = qs["lastName"];
}
这篇关于使用WCF阅读http帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文