iphone中的restweb服务

iphone中的restweb服务,iphone,objective-c,ios,web-services,rest,Iphone,Objective C,Ios,Web Services,Rest,我现在有个问题。我需要向rest服务传递一个transactionID和一个用户密码,它应该返回一个真/假值(XML格式)。但是,它始终返回我(null)。。我完全迷路了,有人请帮忙 NSString *urlString = [NSString stringWithFormat:@"https://10.124.128.93:8443/axis2/services/C3WebService/completeWithdrawal Transaction?transactionId=%@

我现在有个问题。我需要向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 );

我的结果总是返回空值。如何从这里继续?

您可以尝试改用“initWithContentsOfURL:encoding:error:”并选中“error”。另外,使用Charles或其他http嗅探器并将结果与直接的浏览器请求进行比较(您是否在浏览器中检查了结果?

您可以尝试改用“initWithContentsOfURL:encoding:error:”并检查“error”。另外,使用Charles或其他http嗅探器,将结果与直接浏览器请求进行比较(是否在浏览器中检查结果?

考虑使用NSURLConnection,它具有结果回调和获取详细错误详细信息的回调。它不会在UI线程上执行(在请求期间不会挂起UI)

然后,您可以实现委托方法以获取错误、数据和其他详细信息:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
    [connection release];

    NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"result: %@", responseString);

    [responseString release];
}

- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
      NSLog(@"error - read error object for details");
}

考虑使用NSURLConnection,它有一个用于结果的回调,还有一个用于获取详细错误详细信息的回调。它不会在UI线程上执行(在请求期间不会挂起UI)

然后,您可以实现委托方法以获取错误、数据和其他详细信息:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
    [connection release];

    NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"result: %@", responseString);

    [responseString release];
}

- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
      NSLog(@"error - read error object for details");
}

将为您提供有关解析的正确想法。会给你正确的解析方法。没问题。另外,还有其他一些框架,比如RestKit,可以处理更多的这个问题。看看,嘿,布莱恩麦克。。。我收到了“error-readerrorobjectfordetails”消息。。仍然无法连接。。。你知道有什么问题吗?realli非常感谢。嘿,幸运的是,你读了N错误上的所有属性,如原因和本地化说明了吗?他们可能会提供线索。另外,还有一个叫做Charles Proxy的工具,它可以截取并显示http请求的更多细节。那也可能有帮助,没问题。另外,还有其他一些框架,比如RestKit,可以处理更多的这个问题。看看,嘿,布莱恩麦克。。。我收到了“error-readerrorobjectfordetails”消息。。仍然无法连接。。。你知道有什么问题吗?realli非常感谢。嘿,幸运的是,你读了N错误上的所有属性,如原因和本地化说明了吗?他们可能会提供线索。另外,还有一个叫做Charles Proxy的工具,它可以截取并显示http请求的更多细节。这也可能有所帮助。
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
    [connection release];

    NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"result: %@", responseString);

    [responseString release];
}

- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
      NSLog(@"error - read error object for details");
}