SOAP

来源:互联网 发布:人工智能机器人玩具 编辑:程序博客网 时间:2024/06/11 19:09

NSString *msgLength = [NSString stringWithFormat:@"%ld", [soapMsg length]];


    NSString *soapAction=[NSString stringWithFormat:@"%@%@",space,methodname];


    NSURL *url = [NSURL URLWithString:@"http://msp30.coocare.com"];


    AFHTTPClient *httpClient = [[AFHTTPClient allocinitWithBaseURL:url];


    NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:wsUrlparameters:nil];//这里的parameters:参数就是你的第二个问题如何设置参数


    NSDictionary *headField=[NSDictionary dictionaryWithObjectsAndKeys:[urlhost],@"Host",


                             @"text/xml; charset=utf-8",@"Content-Type",


                             msgLength,@"Content-Length",


                             soapAction,@"SOAPAction",nil];


    [request setAllHTTPHeaderFields:headField];


    //超时设置


    [request setTimeoutInterval30 ];


    //访问方式


    [request setHTTPMethod:@"POST"];


    //body内容


    [request setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];


    AFHTTPRequestOperation *operation = [httpClientHTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, idresponseObject) {


           //NSData *html = operation.responseData;


         NSLog(@"返回的字符串~~~~~~~:%@",operation.responseString);



        


        }


                                                                               failure:^(AFHTTPRequestOperation *operation, NSError *error) {


                                                                                   NSLog(@"请求失败=%@",error);


                                                                                   NSString *html = operation.responseString;


                                                                                  NSLog(@"请求失败返回的字符串~~~~~~~:%@",html);


                                                                                }


                                            ];


    [httpClient enqueueHTTPRequestOperation:operation];

0 0
原创粉丝点击