Search code examples
iosobjective-cweb-servicessoapsudzc

SoapRequest to NSString on iOS?


I'm using an API generated by Sudzc.com from a WDSL. I have this method:

- (SoapRequest*) getToolListAsXML: (id <SoapDelegate>) handler getEmptyFC: (BOOL) getEmptyFC repoid: (NSString* ) repoid

And I thought that It calls the webservice and receive an XML as string as the documentation generated by sudzc.com told me:

documentation

But I really don't know how the SoapDelegate works, if I want the response (the list as string) what I'm supposed to do? The examples are more confusing, it says:

examples

But, obviously,

NSString resp = [service getToolListAsXML:self action:@selector(getToolListAsXMLHandler:) getEmptyFC: NO repoid: @""];

doesn't work because of 'incompatible pointer types..."

I'm very new on this so sorry if what I'm saying has nonsense. Thanks.


Solution

  • Try this

        [service getToolListAsXML:self action:@selector(getToolListAsXMLHandler:) getEmptyFC: NO repoid: @""]
        - (void) getToolListAsXMLHandler: (id) value {
    
    if([value isKindOfClass:[NSError class]]) {
            //NSLog(@"%@", value);
            return;
        }
    
        // Handle faults
        if([value isKindOfClass:[SoapFault class]]) {
            //NSLog(@"%@", value);
            return;
        }
        NSString * resp =(NSString *)value;
        }
    

    you will get soap request in string