iOS call soap functions in thread

眉间皱痕 提交于 2019-12-12 04:12:48

问题


guys

I'm a new iOS developer, I'm having a problem when calling soap functions in new thread.

Here is more details:

I have a function calling soap web service:

WebService *webService = [[[WebService alloc]init]retain];
[webService getUser:self action:@selector(getUserHandler) userName: usnm  encPassword: pswd];

This function is simply generated from sudzc.com(Great Website! Thanx!) simply calling this function I can get

<user><username>XXX</username><userStatus>XXX</userStatus><companyCode>XXX</companyCode><password>XXX</password></user>

back from webservice. and my getUserHandler will work perfectly.

but if I want to call the webservice in a thread like this:

[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil];

-(void)myMethod
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"!, %@,%@",usnm,pswd);
    WebService *webService = [[[WebService alloc]init]retain];
    [webService getUser:self action:@selector(getUserHandler) userName: usnm  encPassword: pswd];
    [pool drain];
}

I don't seem to get the returnxml, and it seems the getUserHandler never starts(I put a NSLog in the getUserHandler, but it won't print this time).

I got no idea why is this happening,

any hints are welcome!

Thanx!


回答1:


I highly recommend you to look into the Sync-Async pattern as described in the tutorial here:

Sync-Async Pair Pattern – Easy concurrency on iOS

There is also a question focussing on the same issue:

Multiple async webservice requests NSURLConnection iOS

HTH



来源:https://stackoverflow.com/questions/7001885/ios-call-soap-functions-in-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!