Application works only on a wi-fi

Discussion in 'iOS Programming' started by Shrunga, Dec 5, 2009.

  1. Shrunga macrumors newbie

    Aug 8, 2008
    I'm having a major problem with my application when using anything other than a wifi connection.

    I'm trying to login using a web-service which just return a success or a failure message based on the credentials.

    For some reason it appears that the following code cant locate the host and times out after the time-out period. This happens only when using Edge/3G but NOT wifi.

    I have pasted the code below. I did try with both synchronous and asychronous calls. But in vain.

    Please let me know if there is anything that Im missing out. Im lost on this , any help is heartily appreciated.

    	NSString *theXMLString = [[NSString alloc] initWithFormat:@"%@%@%@%@%@%@%@%@%@%@",
    							  @"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
    							  @"<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\">",
    							  @"<UserLogin xmlns=\"",
    	NSLog(@"Request		:%@",theXMLString);
    	NSString *theWebServiceURLString = [[NSString alloc] initWithFormat:@"%@%@",WEB_SERVICE_URL, @"UserAuthentication.asmx"];
    	NSString *theURLString = [[NSString alloc] initWithFormat:@"%@%@",SOAPACTION_NAMESPACE_URL, @"UserLogin"];
    	NSDictionary *theRequestHeader = [[NSDictionary alloc] initWithObjectsAndKeys:HOST,@"Host",
    	@"text/xml; charset=utf-8", @"Content-Type",
    	NSMutableURLRequest  *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:theWebServiceURLString]
    	[theRequest setHTTPMethod:@"POST"];
    	[theRequest setAllHTTPHeaderFields:theRequestHeader];
    	[theRequest setHTTPBody:[theXMLString dataUsingEncoding:NSUTF8StringEncoding]];
    	[theRequest setHTTPShouldHandleCookies:NO];
    	[theRequest setHTTPShouldHandleCookies:NO];
    	[[NSURLCache sharedURLCache] setMemoryCapacity:0];
    	[[NSURLCache sharedURLCache] setDiskCapacity:0];
    	mURLConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    	[theXMLString release]; theXMLString = nil;
    	[theURLString release ]; theURLString = nil;
    	[theRequestHeader release]; theRequestHeader = nil;
    	[theWebServiceURLString release]; theWebServiceURLString= nil;

Share This Page