iOS iPhone通过get和post方式请求asp.net webservice
来源:互联网 发布:表单用javascript 编辑:程序博客网 时间:2024/05/21 06:53
iPhone中Get和Post方式是本文要介绍的内容,这篇文章,我将通过一个简单的例子来展现iPhone通过get和post方式请求asp.net webservice。
webservice
1、创建一个webservice
2、在webconfig中启用http get 和http post。
<webServices>
<protocols>
<addname="HttpSoap"/>
<addname="HttpPost"/>
<addname="HttpGet"/>
<addname="Documentation"/>
</protocols>
</webServices>
<protocols>
<addname="HttpSoap"/>
<addname="HttpPost"/>
<addname="HttpGet"/>
<addname="Documentation"/>
</protocols>
</webServices>
iphone客户端调用:
1、get的方式:
NSString *queryString=
[NSString stringWithFormat:
@“http://10.5.23.117:5111/Service1.asmx/HelloWorld?param=123%@“,
ipAddress.text];
NSURL *url= [NSURL URLWithString:queryString];
NSMutableURLRequest *req= [NSMutableURLRequest requestWithURL:url];
[req addValue:@“text/xml; charset=utf-8” forHTTPHeaderField:@“Content-Type”];
[req addValue:0 forHTTPHeaderField:@“Content-Length”];
[req setHTTPMethod:@“GET”];
[activityIndicator startAnimating];
conn = [[NSURLConnection alloc] initWithRequest:reqdelegate:self];
if (conn) {
webData = [[NSMutableData data] retain];
}
[NSString stringWithFormat:
@“http://10.5.23.117:5111/Service1.asmx/HelloWorld?param=123%@“,
ipAddress.text];
NSURL *url= [NSURL URLWithString:queryString];
NSMutableURLRequest *req= [NSMutableURLRequest requestWithURL:url];
[req addValue:@“text/xml; charset=utf-8” forHTTPHeaderField:@“Content-Type”];
[req addValue:0 forHTTPHeaderField:@“Content-Length”];
[req setHTTPMethod:@“GET”];
[activityIndicator startAnimating];
conn = [[NSURLConnection alloc] initWithRequest:reqdelegate:self];
if (conn) {
webData = [[NSMutableData data] retain];
}
2、post的方式:
NSString *postString =@"123"; NSURL *url = [NSURL URLWithString: @“http://10.5.23.117:5111/Service1.asmx/HelloWorld2”]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@“%d”, [postString length]]; [req addValue:@“application/x-www-form-urlencoded” forHTTPHeaderField:@“Content-Type”]; [req addValue:msgLength forHTTPHeaderField:@“Content-Length”]; [req setHTTPMethod:@“POST”]; [req setHTTPBody: [postString dataUsingEncoding:NSUTF8StringEncoding]]; [activityIndicator startAnimating]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if (conn) { webData = [[NSMutableData data] retain]; }
- iOS开发之iPhone通过get和post方式请求asp.net webservice
- iOS iPhone通过get和post方式请求asp.net webservice
- iphone之通过get和post方式请求asp.net webservice
- Asp.net GET和POST 请求
- ASP.NET的Get和Post方式
- [Asp.Net]WebService通过URL直接GET请求
- VB.NET通过URL POST请求和GET请求
- VB.NET通过URL POST请求和GET请求
- 通过AsyncTask实现网络请求的方式,get和post
- 通过AsyncTask实现网络请求的方式,get和post
- 请求方式GET和POST
- get和post请求方式
- get和post请求方式
- asp.net获取传值get和post请求
- asp.net获取传值get和post请求
- asp.net获取传值get和post请求
- asp.net自定义获取Get和Post请求的参数
- asp.net自定义获取Get和Post请求的参数
- IOS静态库打造教程
- BCP工具
- JS实现跑马灯效果
- HDU2845--Beans
- Linux常用命令与工具
- iOS iPhone通过get和post方式请求asp.net webservice
- 2013编程之美资格赛【长方形】
- 所有汉字列表
- android中动画的实现
- Ubuntu备份还原
- OK6410 nandflash 1
- ldd3编译misc-modules(ubuntu1204LTS)
- SQL四种语言:DDL,DML,DCL,TCL
- SQL服务启动不了