iphone - iphone中的休息网络服务

标签 iphone objective-c ios web-services rest

我现在有个问题。我需要将一个 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/

相关文章:

ios:在后台排队阻塞并在网络可用时执行

ios - textview 分分钟自动滚动

iphone - Xcode 4 中身份检查器下的标签颜色

ios - 如何在委托(delegate)中加载插页式广告并在另一个 View Controller 中显示?

objective-c - OSX10.5 之前版本中 NSCollectionView 的替代方案,Cocotron?

iphone - 如何使用 setObject : forKey where Key is also a NSMutableDictionary?

ios - 崩溃日志表明应用程序在我的应用程序中不存在的 UIPopoverPresentationController 方法上崩溃

iphone - 如何在 UIScrollView 中获取 UIView 中对象的位置

iphone - 计算 NSDictionary 中的 allKeys 返回 EXC_BAD_ACCESS

iphone - 修改新词典的内容也会修改父词典数据