我目前正在构建一个基于Gsoap工具包的 iPhone 应用程序以连接到 Web 服务。一切正常,除非我在设备上断开并重新连接 3g 后尝试连接到我的服务,我得到:
SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Connection refused"
Detail: connect failed in tcp_connect()
通过调试器工作表明错误来自connect()
. socket.h
我真的不明白,当我启动另一个应用程序(如 safari)时,该设备已连接到 Internet。加载网页后,我的应用程序连接正常。
这是我正在使用的代码:
//GSoap initialization
struct soap soap;
soap_init(&soap);
soap.connect_timeout = 0;
soap.send_timeout = 0;
soap.recv_timeout = 0;
// objects request & response
// struct types can be foundin soapStub.h
struct _ns1__GetAuthentification requete;
struct _ns1__GetAuthentificationResponse reponse;
// init request
requete.ConnectPass = (char *) [connectPass UTF8String];
requete.Login = (char *) [login UTF8String];
requete.Password = (char *) [password UTF8String];
requete.soap = &soap;
// request callback. returns SOAP_OK if something has been returned
if(soap_call___ns1__GetAuthentification(&soap,NULL,NULL, &requete,&reponse) == SOAP_OK){
//then we build the result
NSLog(@"Yay!");
soap_end(&soap); // remove deserialized data and clean up
soap_done(&soap); // detach the gSOAP environment
return authResult;
}
else {
//NSLog(@"Soap Error : GetAuthentification");
// We try to see if there's any problem. @catch statements are here just to keep note of the concerned
// exceptions for each request. No utility for the code.
@try {
[self processFault:&soap];
}
@catch (MMWrongId * e) {
@throw e;
}
@catch (MMConnectionFailed * e) {
@throw e;
}
@catch (MMGetAuthentificationFault * e) {
@throw e;
}
return nil;
}
我是否缺少任何特定的标志/选项?