Search code examples
objective-cweb-servicesdelegatessudzc

Sudz-C Objective-C WebServices logging valid results, but always returning NIL delegate object


I am using SudzC to create a WebService Client, and after some attempts of dealing with configuration, etc., I was able to return data. When I turn on logging within the service, the response logs, as seen below. (I have added spaces to all of the XML tags to enable them to print within StackOverflow. Please accept that the XML works because I have an existing Java application that retrieves this data into JAXB Objects and currently works.)

 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>

However, when I attempt to use a delegate, OR
[service GetDevices:self action:@selector(handleFind:)];
the value in "result" is alway nil.

Any ideas?

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]);
}

Solution

  • I was having a similar problem, and the solution outlined at this link helped: http://code.google.com/p/sudzc/issues/detail?id=40

    Basically - there seems to be a bug in SudzC that hasn't been patched yet, but a one-line change to the Soap.m file works around it.