线程中的iOS调用Soap函数 [英] iOS call soap functions in thread

查看:81
本文介绍了线程中的iOS调用Soap函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新的iOS开发人员,在新线程中调用soap函数时遇到问题.

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

这里有更多详细信息:

我有一个调用soap Web服务的函数:

I have a function calling soap web service:

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

此功能仅是从sudzc.com(很棒的网站!谢谢!)生成的. 只需调用此函数,我就可以得到

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>

从网络服务返回.而且我的getUserHandler会正常工作.

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

我似乎没有得到returnxml,而且似乎getUserHandler从未启动(我在getUserHandler中放置了一个NSLog,但这次不会打印).

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,

欢迎任何提示!

感谢!

推荐答案

我强烈建议您按照本教程中的说明研究Sync-Async模式:

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

同步-异步配对模式–在iOS上轻松并发

还有一个针对同一问题的问题:

There is also a question focussing on the same issue:

多个异步Web服务请求NSURLConnection iOS

HTH

这篇关于线程中的iOS调用Soap函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆