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

posted @ 2012-02-15 10:23  凡娃软件  阅读(764)  评论(0编辑  收藏  举报