How do I pass arrays of values to SudzC-generated webservice classes?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 10:48:26

@Jon Limjap: Lucky you are!!! it asks you for a type which you have dealt before, I have custom class type that SudzC generated for me (!)... It initializes only when passed CXMLNode, (which need CXMLDocument / CXMLElement).. I have no idea how to deal with such type...

an instance is: filter is a class, I have a class of the filter, but there is no way to initialize it, (except alloc-init and then setting its properties, but its properties are another such custom type.. !!!!)...If you know any "trick" to tell/configure sudzc to allow us to pass objects or fetch objects of cocoa type, do tell me....

Mallikarjun

I had similar situation of passing array of objects to SOAP request. I managed to get it working by doing following changes.

SOAP array case in not added in

+(NSString *) serialize: (id) object()
{
//look if it is array not implemented
}

so I managed to change in the following method

+ (NSString*) serialize: (id) object withName: (NSString*) nodeName {
    if([object respondsToSelector:@selector(serialize:)]) {
        if([object isKindOfClass:[SoapArray class]]) 
            return [object serialize:object];
        return [object serialize: nodeName];
    }
    NSString *temp =[NSString stringWithFormat:@"<%@>%@</%@>", nodeName, [Soap serialize: object], nodeName];
    NSLog(@"serialise = %@", temp);
    return temp;
}

at the time SOAP request,

NSMutableArray arr = [[MYTable_STUB_ARR alloc] init]

MYTABLE_OBJ *obj = [[MYTABLE_OBJ alloc] init];

[arr addObject:obj];

[obj release];

Pass element arr object your SOAP Request ??

This is a bit old, but I hope it will help someone. I implemented the serialize: method on SoapArray this way:

- (NSMutableString *)serialize:(NSString *)name
{
    NSMutableString *str = [NSMutableString string];
    //[str appendFormat:@"<%@>", name];
    for (id content in self)
    {
        //[str appendString:[Soap serialize:content]];
        [str appendString:[Soap serialize:content withName:name]];
    }
    //[str appendFormat:@"</%@>", name];
    return str;
}

As you can see, there are some commented lines. If you uncomment them and comment the currently used one inside the for, you will get a tag named name which will contain objects tagged with the content class name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!