restkit - Mapping XML succeeds but object has empty values -
i'm using rkxmlreaderserialization , trying map xml response server object. succeeds, object mapping result has empty values.
here's text/xml response i'm trying map server:
<provision version="1.0"> <fileinfowrapper> <fileurl>somefile.zip</fileurl> <filename>somefile.zip</filename> <filesha1>oi7nk/rfll6dxqcu7ahanfksgke=</filesha1> <filesize>52220448</filesize> <version>13</version> <vital>true</vital> </fileinfowrapper> </provision>
here's model object:
@interface fileinfowrapper : nsobject @property nsstring *fileurl; @property nsstring *filename; @property nsstring *filesha1; @property long filesize; @property nsstring *version; @property bool vital; @end
i've added rkxmlreaderserialization:
[rkmimetypeserialization registerclass:[rkxmlreaderserialization class] formimetype:rkmimetypetextxml]; [[self objectmanager] setacceptheaderwithmimetype:@"application/json,text/xml"];
i think have mapping , response descriptor setup correctly:
rkobjectmapping *fileinfomapping = [rkobjectmapping mappingforclass:[fileinfowrapper class]]; [fileinfomapping addattributemappingsfromdictionary:@{ @"fileurl": @"fileurl", @"filename": @"filename", @"filesha1": @"filesha1", @"filesize": @"filesize", @"version": @"version", @"vital": @"vital"}]; rkresponsedescriptor *fileinforesponsedescriptor = [rkresponsedescriptor responsedescriptorwithmapping:fileinfomapping method:rkrequestmethodget pathpattern:nil keypath:@"provision.fileinfowrapper" statuscodes:rkstatuscodeindexsetforclass(rkstatuscodeclasssuccessful)]; [[self objectmanager] addresponsedescriptor:fileinforesponsedescriptor];
but when call:
[[self objectmanager] getobjectsatpath:@"static/download/installer.info.xml" parameters:nil success:^(rkobjectrequestoperation *operation, rkmappingresult *mappingresult) { nslog(@"****success!****"); nslog(@"mappingresult: %@", mappingresult); fileinfowrapper *fileinfo = [mappingresult firstobject]; nslog(@"url: %@", [fileinfo fileurl]); nslog(@"name: %@", [fileinfo filename]); nslog(@"sha1: %@", [fileinfo filesha1]); nslog(@"size: %lx", [fileinfo filesize]); } failure:^(rkobjectrequestoperation *operation, nserror *error) { nslog(@"****failure!****"); }];
all values null:
i restkit.network:rkobjectrequestoperation.m:180 'http://example.com/static/download/installer.info.xml' restkit.network:rkobjectrequestoperation.m:250 'http://example.com/static/download/installer.info.xml' (200 ok / 1 objects) [request=0.1080s mapping=0.0060s total=0.1226s] ****success!**** mappingresult: <rkmappingresult: 0x10064b190, results={ "provision.fileinfowrapper" = "<fileinfowrapper: 0x10065f780>"; }> url: (null) name: (null) sha1: (null) size: 0
what doing wrong?
update: turned on restkit/objectmapping logging , got additional info:
d restkit.object_mapping:rkmapperoperation.m:377 executing mapping operation representation: { provision = { fileinfowrapper = { filename = { text = "somefile.zip"; }; filesha1 = { text = "oi7nk/rfll6dxqcu7ahanfksgke="; }; … } , targetobject: (null) t restkit.object_mapping:rkmapperoperation.m:320 examining keypath 'provision.fileinfowrapper' mappable content... d restkit.object_mapping:rkmapperoperation.m:300 found mappable data @ keypath 'provision.fileinfowrapper': { filename = { text = "somefile.zip"; }; filesha1 = { text = "oi7nk/rfll6dxqcu7ahanfksgke="; }; … } d restkit.object_mapping:rkmapperoperation.m:231 asked map source object { filename = { text = "somefile.zip"; }; filesha1 = { text = "oi7nk/rfll6dxqcu7ahanfksgke="; }; … } mapping <rkobjectmapping:0x10025e6b0 objectclass=fileinfowrapper propertymappings=( "<rkattributemapping: 0x10025ebc0 filesha1 => filesha1>", "<rkattributemapping: 0x10025ed90 filename => filename>" … )> d restkit.object_mapping:rkmappingoperation.m:952 starting mapping operation... t restkit.object_mapping:rkmappingoperation.m:953 performing mapping operation: <rkmappingoperation 0x10068f730> 'fileinfowrapper' object. mapping values object { filename = { text = "somefile.zip"; }; filesha1 = { text = "oi7nk/rfll6dxqcu7ahanfksgke="; }; … } object <fileinfowrapper: 0x10068f290> object mapping (null) t restkit.object_mapping:rkmappingoperation.m:550 mapping attribute value keypath 'fileurl' 'fileurl' t restkit.object_mapping:rkmappingoperation.m:431 found transformable value @ keypath 'fileurl'. transforming type '__nsdictionarym' 'nsstring' d restkit.object_mapping:rkpropertyinspector.m:130 cached property inspection class 'fileinfowrapper': { filename = { isprimitive = 0; keyvaluecodingclass = nsstring; name = filename; }; filesha1 = { isprimitive = 0; keyvaluecodingclass = nsstring; name = filesha1; }; … } t restkit.object_mapping:rkmappingoperation.m:583 skipped mapping of attribute value keypath 'fileurl keypath 'fileurl' -- value unchanged ((null)) t restkit.object_mapping:rkmappingoperation.m:550 mapping attribute value keypath 'filesha1' 'filesha1' t restkit.object_mapping:rkmappingoperation.m:431 found transformable value @ keypath 'filesha1'. transforming type '__nsdictionarym' 'nsstring' t restkit.object_mapping:rkmappingoperation.m:583 skipped mapping of attribute value keypath 'filesha1 keypath 'filesha1' -- value unchanged ((null)) …
it appears have map text node. post had same problem:
restkit 0.20-pre3 rkxmlreaderserialization , xmlreader
changing mapping to:
[fileinfomapping addattributemappingsfromdictionary:@{ @"fileurl.text": @"fileurl", @"filename.text": @"filename", @"filesha1.text": @"filesha1", @"filesize.text": @"filesize", @"version.text": @"version", @"vital.text": @"vital",}];
did it.
Comments
Post a Comment