如何将值数组传递给 SudzC 生成的 Web 服务类?

发布于 2024-10-17 03:13:52 字数 799 浏览 1 评论 0原文

我有一个从 WSDL 生成的 sudzc 服务类,它接受 ArrayOfInt 和 ArrayOfString 对象作为参数。服务方法签名是这样的:

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

我的问题是,如何将值传递到需要 NSMutableArrays 的参数中?

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

然而,我尝试过的这些方法都不起作用:

  • 直接传递 (int) 对象的 NSArray/NSMutableArray
  • 直接传递 NSNumber 对象的 NSArray/NSMutableArray
  • 传递包含 @"1"、@"2"、@ 的字符串数组"3" 等
  • 传递已包含 @"1"@"2" 的字符串数组> 等
  • 根据整数从字符串中构造 CXMLDocument

我确信下载中的随附文档对此进行了某种解释 - 目前我还不清楚。

I have a sudzc service class generated from a WSDL that accepts an ArrayOfInt and ArrayOfString objects as parameters. The service method signature is this:

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

My question is, how do I pass values into the parameters that expect NSMutableArrays?

In the above method signature, the "displayedAttributes" parameter is expecting an ArrayOfInt object (which should be populated with several integers in an int tag, e.g., <int>1</int><int>2</int><int>3</int> etc).

However none of these things which I've tried have worked:

  • Directly passing an NSArray/NSMutableArray of (int) objects
  • Directly passing an NSArray/NSMutableArray of NSNumber objects
  • Passing an array of strings containing @"1", @"2", @"3" etc
  • Passing an array of strings that already contain @"<int>1</int>", @"<int>2</int>", etc
  • Constructing a CXMLDocument out of a string based on the integers

I'm sure this is somehow explained in the accompanying documentation in the download -- it's just not clear to me at the moment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

反差帅 2024-10-24 03:13:52

@Jon Limjap:你很幸运!它要求你提供一个你之前处理过的类型,我有 SudzC 为我生成的自定义类类型(!)...它仅在传递 CXMLNode 时初始化,(需要 CXMLDocument / CXMLElement)..我不知道如何处理这样的类型...

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

@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....

逆光飞翔i 2024-10-24 03:13:52

我也遇到过类似的情况,将对象数组传递给 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 请求?

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 ??

娇妻 2024-10-24 03:13:52

这有点旧,但我希望它能对某人有所帮助。我以这种方式在 SoapArray 上实现了 serialize: 方法:

- (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 的标记,其中包含用内容类名称标记的对象。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文