当前位置:编程学习 > asp >>

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];

 

摘自 凡娃软件
补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,