zoukankan      html  css  js  c++  java
  • 关于ios iphone 调用asp.net webservice 的使用

    -(void)testPOST

    {

        NSError *error;

        NSURLResponse *theResponse;

        

        NSURL *url = [NSURL URLWithString:

                      @"http://192.168.0.2:12/app/post.asmx"];

        NSMutableURLRequest *req = [NSMutableURLRequestrequestWithURL:url];

        //NSString *msgLength = [NSString stringWithFormat:@"%d", [postString length]];

        [req addValue:@"application/x-www-form-urlencoded"forHTTPHeaderField:@"Content-Type"];

        [req setHTTPMethod:@"POST"];

        //[req setValue:@"0" forHTTPHeaderField:@"StarIndex"];

        //[req setValue:@"10" forHTTPHeaderField:@"EndIndex"];

        //[req setHTTPBody: [postString dataUsingEncoding:NSUTF8StringEncoding]];

        NSString *postUrl=@"StarIndex=0&EndIndex=10";  

        [req setHTTPBody:[postUrl dataUsingEncoding:NSUTF8StringEncoding]];

        NSData *data=[NSURLConnectionsendSynchronousRequest:req returningResponse:&theResponse error:&error];

        NSLog(@"POSTDATA %@",[[NSStringalloc] initWithData:data encoding:NSUTF8StringEncoding]);    

        

    }

    -(void)testGET

    {

        NSString *queryString =

        [NSStringstringWithFormat:

         @"http://192.168.0.2:12/app/get.asmx/getlist&StarIndex=0&EndIndex=10"];

        NSURL *url = [NSURL URLWithString:queryString];

        NSMutableURLRequest *req = [NSMutableURLRequestrequestWithURL:url];

        [req addValue:@"text/xml; charset=utf-8"forHTTPHeaderField:@"Content-Type"];

        [req addValue:0forHTTPHeaderField:@"Content-Length"];

        [req setHTTPMethod:@"GET"];

        

        NSError *error;

        NSURLResponse *theResponse;

        NSData *data=[NSURLConnectionsendSynchronousRequest:req returningResponse:&theResponse error:&error];

        NSLog(@"GETDATA %@",[[NSStringalloc] initWithData:data encoding:NSUTF8StringEncoding]);

        

    }

  • 相关阅读:
    分页查询+组合查询
    单点登录3
    单点登录2
    单点登录1
    sql server 语句
    jsTree动态加载数据
    sql 根据日期模糊查询&SQL Server dateTime类型 模糊查询
    快捷键
    JQUERY获取当前页面的URL信息
    C#中的?和??的用法
  • 原文地址:https://www.cnblogs.com/Rampage/p/2494689.html
Copyright © 2011-2022 走看看