开发者

Having a problem with a method not being called when NSURLConnection finishes

I will try my best to explain what's going on. The app that I'm working on relies on soap services extensively. Since I'm making so many calls to different services I figured I would take a shot at creating my own webservice class. My new class is named SoapServiceRequest. I've defined a few instance variables along with one method. This one method takes 4 arguments: 1) username 2) password 3) serviceName (defined service on soap server) 4) withData (data sending to soap server)

I create an instance of this class, pass in the required 4 arguments but the method stops running midway. This method does the following...

builds the soap message sets up the URL and connection sends the data sends the response back to th开发者_JS百科e App (dumping to NSLog) and when the "-(void)connectionDidFinishLoading:(NSURLConnection *)connection" method is called I am setting up an XMLParser to parse the returned data.. NSXMLParser will then call its delegate methods. I am not seeing the XmlParser fire.

The SoapServiceRequest class has the XMLParser defined. It appears that this is not being called. I wanted to setup this class and override a couple of methods in my other subclasses.

For example. I am changing a password from within my app via webservice. This works fine I am just not seeing the XML being returned of either true/false. The method ends on "-(void)connectionDidFinishLoading:(NSURLConnection *)connection" and the XMLParser never gets called.

Below is what my connectionDidFinishLoading looks like.

//--parser to begin parsing our returned xml.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{
    NSLog(@"Done.  Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc]initWithBytes:[webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];    
        //--show the XML--
    NSLog(@"%@",theXML);

    if (xmlParser) {
        [xmlParser release];
    }

    xmlParser = [[NSXMLParser alloc] initWithData:webData];
    [xmlParser setDelegate:self];
    [xmlParser setShouldResolveExternalEntities:YES];
    [xmlParser parse];

    [connection release];
    [webData release];
}

If my return data is true inform the user of success or just update the label, if false let user know etc.. Any suggestions on where to look?

Thanks.


I had an error in my class definition in the XMLParser which is why the parser never did get called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜