ayuda con Restkit

lauchon

Weon Pro
Abr 15, 2006
2,264
2
Frogoids
0.0
Estimados,

Soy bastante nuevo en objective-c y este problema todavia no lo puedo resolver

Tengo que obtener los datos de un webservice que devuelve el siguiente XML por metodo GET

<?xml version="1.0" encoding="utf-8"?>
<Piece xmlns="http://microsoft.com/webservices/">
<valor1>string</valor1>
<valor2>string</valor2>
<valor3>string</valor3>
</Piece>


Tengo el siguiente codigo en objective-c con Restkit 0.20.0

PHP:
    [RKMIMETypeSerialization registerClass:[RKURLEncodedSerialization class] forMIMEType:@"text/xml"];
   
    RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[MyClass class]];
    [objectMapping addAttributeMappingsFromDictionary:@{ @"valor1": @"valor1", @"valor2": @"valor2", @"valor3": @"valor3" }];
   
    //  Set up the response descriptor
    RKResponseDescriptor *responseDescriptor =
    [RKResponseDescriptor
    responseDescriptorWithMapping:objectMapping
    pathPattern:nil
    keyPath:@"Piece"
    statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
   
 
    NSMutableString *Link = [NSMutableString stringWithString:@"http://url?Parametro="];
    [Link appendString:parametro.text];
   
    NSURL *URL = [NSURL URLWithString:Link];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];
    RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc]
                                          initWithRequest:request responseDescriptors:@[responseDescriptor]];
    [operation setCompletionBlockWithSuccess:
    ^(RKObjectRequestOperation *operation, RKMappingResult *result) {
        NSArray *myArray = result.array;
        for (MyClass *p in myArray) {
            NSLog(@"Name:  %@", p.valor1);
        }
    } failure:^(RKObjectRequestOperation *operation, NSError *error)
    {
        RKLogError(@"Operation failed with error: %@", error);
    }];    [operation start];
Y al ejecutarlo recibo el siguiente mensaje en el Output

Operation failed with error: Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No mappable object representations were found at the key paths searched." UserInfo=0x86654a0 {DetailedErrors=(
), NSLocalizedFailureReason=The mapping operation was unable to find any nested object representations at the key paths searched: Piece
The representation inputted to the mapper was found to contain nested object representations at the following key paths: <?xml version
This likely indicates that you have misconfigured the key paths for your mappings., NSLocalizedDescription=No mappable object representations were found at the key paths searched., keyPath=null}
No entiendo por que dice que el KeyPath esta mal si la estructura del XML comienza con el nodo Piece y dentro de el los datos.

Saludos.
Gracias.