2011-02-09 48 views
4

我有一个从接受ArrayOfInt和ArrayOfString对象作为参数的WSDL生成的sudzc服务类。该服务方法的签名是这样的:如何将值数组传递给SudzC生成的webservice类?

- (SoapRequest*) Search: (id <SoapDelegate>) handler filters: (NSMutableArray*) displayedAttributes: (NSMutableArray*) displayedAttributes; 

我的问题是,我怎么传值到意想不到NSMutableArrays参数?

在上面的方法签名中,“displayedAttributes”参数需要一个对象(应在int标记中填充多个整数,例如<int>1</int><int>2</int><int>3</int>等)。

但是没有这些东西,我已经试过了工作:

  • 直接传递的一个NSArray/NSMutableArray里(INT)对象
  • 直接传递的NSNumber的一个NSArray/NSMutableArray的对象
  • 传包含@“1”,@“2”,@“3”等的字符串数组
  • 传递已包含的字符串数组,等
  • Co nstructing一个CXMLDocument了基于整数

一个字符串的我敢肯定,这是在下载所附文件在某种程度上解释 - 它只是我不明白的时刻。

回答

0

我有类似的情况传递对象数组到SOAP请求。我设法通过进行以下更改来实现它。

SOAP阵列情况下在

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

没有添加所以我管理在以下方法

+ (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; 
} 

在时间SOAP请求以改变,

NSMutableArray arr = [[MYTable_STUB_ARR alloc] init] 

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

[arr addObject:obj]; 

[obj release]; 

通行证元件ARR对你的SOAP请求?

0

这有点旧,但我希望它能帮助别人。我实现了serialize:方法上SoapArray这样:

- (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; 
} 

正如你所看到的,也有一些注释行。如果取消对它们的注释并在for内部注释当前使用的内容,您将得到一个名为name的标记,其中将包含标记有内容类名称的对象。

1

@Jon Limjap:幸运的是你!它会询问你之前处理过的类型,我有SudzC为我生成的自定义类类型(!)...它仅在传入CXMLNode(需要CXMLDocument/CXMLElement)时才初始化..我不知道如何处理这样的类型...

一个实例是:filter是一个类,我有一个过滤器的类,但是没有办法初始化它,(除了alloc-init,然后设置它的属性,但它的属性属性是另一种这样的自定义类型.. !!!!)...如果你知道任何“技巧”来告诉/配置sudzc允许我们传递对象或获取可可类型的对象,请告诉我......