我现在有个问题。我需要将一个 transactionID 和一个用户密码传递给一个休息服务,它应该返回一个真/假值(以 XML 格式)。但是,它一直在返回我(null)。我完全失去了一些人请帮助。
NSString *urlString = [NSString stringWithFormat:@"https://10.124.128.93:8443/axis2/services/C3WebService/completeWithdrawal Transaction?transactionId=%@&password=%@", _transactionID.text, _userPassword.text];
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSString *result = [[NSString alloc] initWithContentsOfURL:url];
NSLog(@"%@",result );
我的结果总是让我返回 null。我如何从这里继续?
最佳答案
.h:
NSMutableData *responseData;
.m:
- (void)load {
NSURL *myURL = [NSURL URLWithString:@"https://10.124.128.93:8443/axis2/services/C3WebService/completeWithdrawal Transaction?transactionId=%@&password=%@", _transactionID.text, _userPassword.text];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
responseData = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[responseData release];
[connection release];
[textView setString:@"Unable to fetch data"];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Succeeded! Received %d bytes of data",[responseData
`enter code here` length]);
NSString *txt = [[[NSString alloc] initWithData:responseData encoding: NSASCIIStringEncoding] autorelease];
}
关于iphone - iphone中的休息网络服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7269780/