2011-02-09 50 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允許我們傳遞對象或獲取可可類型的對象,請告訴我......