1

我正在使用 SudzC 创建一个 WebService 客户端,经过一些尝试处理配置等,我能够返回数据。当我在服务中打开日志记录时,响应日志,如下所示。(我在所有 XML 标记中添加了空格,以使它们能够在 StackOverflow 中打印。请接受 XML 可以正常工作,因为我有一个现有的 Java 应用程序可以将此数据检索到 JAXB 对象中并且目前可以正常工作。)

 2012-03-13 11:21:43.936 SampleProject[976:f803] 
< SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
    < SOAP-ENV:Header/ >
    < SOAP-ENV:Body >
        < ns2:GetDevicesResponse xmlns:ns2="http://somesite.com/cayman/schemas" >
            < ns2:Devices>
                < ns2:DeviceName>Neelam 65< /ns2:DeviceName>
                < ns2:DeviceName>Neelam 66< /ns2:DeviceName>
            < /ns2:Devices>
        < /ns2:GetDevicesResponse>
    < /SOAP-ENV:Body>
< /SOAP-ENV:Envelope>

但是,当我尝试使用委托时,或者
[service GetDevices:self action:@selector(handleFind:)];
“结果”中的值始终为零。

有任何想法吗?

XpressViewViewController.h

@interface XpressViewViewController : UIViewController <SoapDelegate>

...

XpressViewViewController.m

@implementation XpressViewViewController

...

- (IBAction)initiateService:(id)sender {

    CaymanService* service = [[CaymanService alloc]init];

    service.logging = YES;

    NSMutableDictionary * headers = [[NSMutableDictionary alloc]init];
    SoapLiteral *soapLiteral =[SoapLiteral literalWithString: @"<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><wsse:UsernameToken xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><wsse:Username>DUMMY</wsse:Username><wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">test</wsse:Password></wsse:UsernameToken></wsse:Security>"];

    [headers setValue:soapLiteral forKey:@"header"]; 

    [service setHeaders: headers];

    [service setNamespace:@"http://company.com/cayman/schemas"];

    //SoapRequest *sr = [service GetDevices:self action:@selector(handleFind:)];
    //NSLog(@"Request: ", sr.description);

    [service GetDevices:self];
}

     - (void) onload: (id) result;
{
    //Why are you ALWAYS nil...What am I missing???
    NSLog(@"Data: %@", result);
}

 - (void) onerror: (NSError*) error;
{
    NSLog(@"Error: %@", error);
}
 - (void) onfault: (SoapFault*) fault;
{
    NSLog(@"Fault: %@", fault);    
}
-(void)handleFind: (id) result {
    if([result isKindOfClass: [NSError class]]) {
        NSLog(@"Error: %@",result);
        return;
    }

    if([result isKindOfClass: [SoapFault class]]) { 
        NSLog(@"Error: %@",result);

        return;
    }

    // This doesn't matter because result is ALWAYS nil
    NSArray *data = [[NSArray alloc ]initWithArray: result];
    NSLog(@"We have %@ devices ", [NSNumber numberWithInt:data.count]);
}
4

1 回答 1

2

我遇到了类似的问题,此链接中概述的解决方案有所帮助: http ://code.google.com/p/sudzc/issues/detail?id=40

基本上 - SudzC 中似乎有一个尚未修补的错误,但是对 Soap.m 文件的单行更改可以解决它。

于 2012-04-24T08:07:11.897 回答