处理目标C中的肥皂信封

时间:2012-10-09 12:36:06

标签: iphone soap nsstring sudzc

我正在尝试使用sudzc.com访问iOS中的SOAP Web服务。似乎我得到肥皂信封作为回报。但我不确定如何处理结果。我可以以某种方式将结果放在NSDictionary中,或者我该如何处理?

    - (void)run {
// Create the service
SDZDevices2Api* service = [SDZDevices2Api service];
service.logging = YES;
    // Returns NSString*. (added searchstring and max count values)
[service LocationFindSimple:self action:@selector(LocationFindSimpleHandler:) SearchString: @"Vejle" Max: 1 BankId: [NSMutableArray array] BankName: [NSMutableArray array] Id: [NSMutableArray array] Name: [NSMutableArray array] Icon: [NSMutableArray array] Zip: [NSMutableArray array] Attributes: [NSMutableArray array]];
   }

// Handle the response from LocationFindSimple.

- (void) LocationFindSimpleHandler: (id) value {

// Handle errors
if([value isKindOfClass:[NSError class]]) {
    NSLog(@"%@", value);
    return;
}

// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
    NSLog(@"%@", value);
    return;
}

// Do something with the NSString* result
  NSString* result = (NSString*) value;
    NSLog(@"LocationFindSimple returned the value: %@", result);
}

这是日志消息:

http://pastebin.com/JycGq4Du

1 个答案:

答案 0 :(得分:0)

我用这个来帮助别人:Here

if( [value isKindOfClass:[NSError class]] || [value isKindOfClass:[SoapFault class]] ) 
{

NSLog(@"%@", [value description]);
return;
}

// Verify we're a dictionary
if( ![value isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: Response not a dictionary");
return;
}

NSDictionary* dict = (NSDictionary*)value;
NSDictionary* resp = [dict objectForKey:@"E_AN"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: E_AN not a dictionary");
return;
}
dict = [resp objectForKey:@"item"];
if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: item not a dictionary");
return;
}
resp = [dict objectForKey:@"MANDT"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: MANDT not a dictionary");
return;
}
相关问题