【发布时间】:2011-03-13 08:17:57
【问题描述】:
我已经让 WCF 服务(service1.svc)有 2 种方法。
1.GetData()
2.ProductDetails(字符串 ProdId)
当我这样做时,两者都返回 JSON 格式的文件。
http://192.x.x.x/Demo/Service1.svc/GetData
http://192.x.x.x/Demo/Service1.svc/ProductDetails?prodId=P2
现在我想在 Iphone 中使用这些方法。
&我称它们为-
NSDictionary *arrayDict=[[NSDictionary alloc]init];
NSString *requestString = [NSString stringWithFormat:@"%@", [arrayDict JSONFragment], nil];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *url = [NSString stringWithFormat:@"http://192.x.x.x/Demo/Service1.svc/ProductDetails/prodId=%@",@"P2"];
NSLog(@"URL %@",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody: requestData];
theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
所以请告诉我如何在 Iphone 中调用此方法[ProductDetails(string ProdId)]
【问题讨论】: