sanshelly / wsdl2objc

Automatically exported from code.google.com/p/wsdl2objc
MIT License
0 stars 0 forks source link

wsdl complex return objects fix #193

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Acctually it is not an issue its bug fix as i found that complex return objects 
cannot be parsed i had changed the code to solve it so i want to share it with 
you to invoke it in next version
1-
File name:USType.m
Changes:(Added)

After line 201 ([returning setObject:([schema.fullName 
isEqualToString:schema.wsdl.targetNamespace.fullName] ? @"true" : @"false")  
forKey:@"isInTargetNamespace"];) add:

 [returning setObject:(([sequenceElements count] == 0 && [attributes count]==0) ? @"true" : @"false") forKey:@"useDictionaryToStoreResult"];

2-
File name:ComplexType_H.template
Changes:(Added)

a-
After line 23 (%ENDIF) add:
%IF useDictionaryToStoreResult
NSMutableDictionary* resultAsDictionary;
%ENDIF

b-
After line 77 in modified or 74 in original (%ENDIF) add:
%IF useDictionaryToStoreResult
-(NSMutableDictionary*) getResultAsDictionary;
%ENDIF

3-
File name:ComplexType_M.template
Changes:(Added)

a-
After line 18 (%ENDIF) add:
%IF useDictionaryToStoreResult
        resultAsDictionary= [NSMutableDictionary dictionary];
%ENDIF

b-
After line 234 in modified or 231 in original (%IF PrintComments) add:
%IF useDictionaryToStoreResult
-(NSMutableDictionary*) getResultAsDictionary
{
    return resultAsDictionary;
}
%ENDIF

c-
After line 377 in modified or 368 in original  (}) add:
%IF useDictionaryToStoreResult
-(void)deserializeElementsFromNodeExt:(xmlNodePtr)cur 
andResultIn:(NSMutableDictionary*)dic{
    unsigned long childrenCount=xmlChildElementCount(cur);
    if(childrenCount == 0) {
        xmlNodePtr child =cur->children;
        if(child->type == XML_TEXT_NODE) {
            xmlChar *elementText = xmlNodeListGetString(cur->doc, child, 1);
            NSString *elementString = nil;

            if(elementText != NULL) {
                elementString = [NSString stringWithCString:(char*)elementText encoding:NSUTF8StringEncoding];
                [elementString self]; // avoid compiler warning for unused var
                xmlFree(elementText);
            }

            NSString *elementName = nil;

            if(cur->name != NULL) {
                elementName = [NSString stringWithCString:(char*)(cur->name) encoding:NSUTF8StringEncoding];
                [dic setObject:elementString forKey:elementName];
            }
        }
    }
    else
    {
        NSMutableDictionary*subResult=[NSMutableDictionary dictionary];
        for(xmlNodePtr child = cur->children ; child != NULL ; child = child->next ) {
           [self deserializeElementsFromNodeExt:child andResultIn:subResult];       
        }
        NSString *elementName = nil;
        if(cur->name != NULL) {
            elementName = [NSString stringWithCString:(char*)(cur->name) encoding:NSUTF8StringEncoding];
        }
        int childCounter=0;
        while ([dic objectForKey:[NSString stringWithFormat:@"%@%d",elementName,childCounter]]!=nil) {
            childCounter++;
        }
        [dic setObject:subResult forKey:[NSString stringWithFormat:@"%@%d",elementName,childCounter]];
    }

}
%ENDIF

d-
After line 429 in modified or 377 in original (%ENDIF) add:
%IF useDictionaryToStoreResult
    [self deserializeElementsFromNodeExt:cur andResultIn:resultAsDictionary];
%ENDIF

Original issue reported on code.google.com by mazzi...@gmail.com on 20 Dec 2012 at 9:52

Attachments: