iPhone开发 调用阿asp.net程序的webservice
//asp.net中的web.config中,需要开启get方式或者post方式
<system.web>
<webServices>
<protocols>
<add name="HttpSoap">
<add name="HttpPost">
<add name="HttpGet">
<add name="Documentation">
</protocols>
</webService>
</system.web>
//iphone 代码
NSString *urlString = @"http://www.yoursite.com/web.asmx/HelloWorld2?say=aaabbbccc";
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoadtimeoutInterval:30];
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
NSString* retStr = [[NSStringalloc] initWithData:urlData encoding:NSUTF8StringEncoding];
摘自 凡娃软件
相关新闻>>
- 发表评论
-
- 最新评论 更多>>