SudzC workaround for SOAPRequest to deserialize into NSMutableArray of custom objects

629 Views Asked by At

This is my SoapRequest:

SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"" postData: _envelope deserializeTo: /*[[DMDDmdInfo alloc] autorelease]*/ [NSMutableArray array]];

I should receive NSMutableArray of DMDDmdInfo objects. Instead I receive NSMutableArray of NSDictionaries.

This is what I have in SoapRequest:connectionDidFinishLoading:

CXMLNode* element = [[Soap getNode: [doc rootElement] withName: @"Body"] childAtIndex:0];
    if(deserializeTo == nil) {
        output = [Soap deserialize:element];
    } else {
        if([deserializeTo respondsToSelector: @selector(initWithNode:)]) {
            //element = [element childAtIndex:0];
            output = [deserializeTo initWithNode: element];
        } else {
            NSString* value = [[[element childAtIndex:0] childAtIndex:0] stringValue];
            output = [Soap convert: value toType: deserializeTo];
        }
    }

Could you please help me solving this issue, to get the desired results: NSMutableArray of DMDDmdInfo objects?

2

There are 2 best solutions below

2
On

although I am still working on it, in my project I used the following code to get a NSMutableArray of the returned objects. I also made some tweaks to SoapRequest.m but you should try first with this little change and see if it works

SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"" postData: _envelope deserializeTo: [[[NSMutableArray alloc] init] autorelease]];
0
On

The following code worked for me, we need to specify the SoapArray object for deserializeToparam

SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"" postData: _envelope deserializeTo: [[[SoapArray alloc] init] autorelease]];