首页 新闻 会员 周边

wcf的回调接口(要求post请求)

0
悬赏园豆:20 [待解决问题]
 1  public class Service1 : IService1
 2     {
 3         public string ShowName(string name)
 4         {
 5             #region  //发送请求的数据
 6             //发送请求的数据
 7             WebRequest myHttpWebRequest = WebRequest.Create("http://localhost:8588/api/Contact");
 8             myHttpWebRequest.Method = "POST";
 9             UTF8Encoding encoding = new UTF8Encoding();
10             byte[] byte1 = encoding.GetBytes(name);
11             myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
12             myHttpWebRequest.ContentLength = byte1.Length;
13             Stream newStream = myHttpWebRequest.GetRequestStream();
14             newStream.Write(byte1, 0, byte1.Length);
15             newStream.Close();
16             #endregion
17             //发送过去后对方没有返回    而是回调我们的接口  
18             //1.这个回调接口用wcf怎么写?(要求:用post请求)
19             //2.对方回调我们接口会传入他们那边的操作结果,我们返回success(但我要在这个位置得到他们传过来的东西)
20
21             //return 他们调用我们的回调接口传过来的参数(这里直接结束)
22 
23 
24             //下面的就没有了
25             #region  
26             //发送成功后接收返回的XML信息
27             HttpWebResponse response = (HttpWebResponse)myHttpWebRequest.GetResponse();
28             string lcHtml = string.Empty;
29             Encoding enc = Encoding.GetEncoding("UTF-8");
30             Stream stream = response.GetResponseStream();
31             StreamReader streamReader = new StreamReader(stream, enc);
32             lcHtml = streamReader.ReadToEnd();
33             #endregion
36             return lcHtml;
37         }
孩丿的主页 孩丿 | 初学一级 | 园豆:134
提问于:2017-04-09 19:55
< >
分享
所有回答(1)
0

为何 我项目中的WCF 不需要写这么多东西...  锲约,接口

Sen7 | 园豆:250 (菜鸟二级) | 2017-04-10 11:48

这个关系比较复杂      网站程序------>wcf程序------->post请求别人的接口(wcf得到结果)------>网站项目

支持(0) 反对(0) 孩丿 | 园豆:134 (初学一级) | 2017-04-10 18:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册