Sudzc iPhone SOAP - How can I handle a SOAP fault using this library auto-generated data?

997 Views Asked by At

I have a response, which returns SOAP fault in case of exception. I want to handle this SOAP Fault. But, the response I get by deserializing the SOAP response does not have a SOAP Fault.

I have used Sudzc Library to generate the objective C code for my web services.

Help will be appreciated.

Thanks,

Priya

2

There are 2 best solutions below

1
On BEST ANSWER

There seems to be a bug in the SoapRequest.m that is bundled with Sudzc.

Specifically, if you take a look at the

- (void)connectionDidFinishLoading:(NSURLConnection *)connection;

method and navigate to the following bit of code:

id output = nil;
SoapFault* fault = [SoapFault faultWithXMLDocument: doc];

if([fault hasFault]) {
    if(self.action == nil) {
        [self handleFault: fault];
    } else {
        if(self.handler != nil && [self.handler respondsToSelector: self.action]) {
            [self.handler performSelector: self.action withObject: output];
        } else {
            NSLog(@"SOAP Fault: %@", fault);
        }
    }
}

You can see that output will always be nil when returned to the handler.

To fix this issue, you can simply return the SoapFault instead of the output to your handler like so:

...
[self.handler performSelector: self.action withObject: fault];
...
1
On

In your Sudzc return Handler Method, you can [idOfSoapObject isKindOfClass:[SoapFault class]]

If you are already doing this, then I would suggest turning Logging on: your service will have a .logging(BOOL) property. This will log the full soap requests and responses. Here you can check the response manually for a fault.