Use Http Post to call Web Service
来源:互联网 发布:虚拟机 网络设置 编辑:程序博客网 时间:2024/06/05 05:15
[WebMethod]
public bool IsUserExist(string userName) {
if (userName == "raymond")
return true;
else
return false;
}
protected void Button2_Click(object sender, EventArgs e)
{
byte[] data = System.Text.Encoding.ASCII.GetBytes("userName=" + TextBox1.Text);
System.Net.WebRequest request = System.Net.HttpWebRequest.Create(
"http://localhost/samples/MyService.asmx/IsUserExist");
request.Method = "POST";
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
System.IO.Stream str = request.GetRequestStream();
str.Write(data, 0, data.Length);
str.Flush();
System.Net.WebResponse response = request.GetResponse();
System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
string result = reader.ReadToEnd();
TextBox2.Text = result; // the result here is xml format, you need to handle this
}
0 0
- Use Http Post to call Web Service
- Use VBA to call Web Service
- Using WinInet to call a Web service
- SAP 发送 HTTP POST(Web Service)
- Http Post 方式访问Web Service
- How to use HttpURLConnection POST data to web server?
- How to use HttpURLConnection POST data to web server?
- How to use VC++6.0 to develop web Service Client
- use c to send file using http post
- how to call Web service in Excel 2003 / Excel 2005
- Use java.net.HttpURLConnection/HttpClient 访问web service ( HTTP/HTTPS)
- VB call Web Service
- call web service failed
- Call JMS Web Service
- Use Web Service
- Domino代理调用远程Web Service(HTTP POST)
- How to use HttpWebRequest to send POST request to another web server?
- How to use HttpWebRequest to send POST request to another web server?
- hdu1247 Hat’s Words (字典树)
- sublime 自动注释 插件 DocBlockr
- 用新浪微博API获取微博数据
- 236. Lowest Common Ancestor of a Binary Tree
- Opencv图像识别从零到精通(18)-------击中击不中
- Use Http Post to call Web Service
- Camera 预览之SurfaceView、TextureView、GLSurfaceView(三)
- GZIP压缩原理分析(16)——第五章 Deflate算法详解(五07) 算法分析(01) 本节概述
- poj 1681 Painter's Problem 【高斯消元 枚举自由变元】
- linux 之Mysql 同步复制
- 解决Android Studio 2.1.2 安装后找不到SDK
- Leetcode Pascal's Triangle II
- 每次记录一点Idea的使用心得
- leetcode之Largest Rectangle in Histogram