我从 iOS 代码调用这个网络服务但是当我从我的 iOS 代码中的同一个请求调用时,它没有给我响应。像这样收到致命错误或响应字节 0。
当我从 iOS 代码发布时,我会检查服务器,但原因是我的请求无法在服务器上成功到达。
任何人都可以知道为什么我的请求无法在服务器上到达?
这是我的IOS代码...
-(IBAction)FindWords:(id)sender
{
NSString *sSOAPMessage = @"<HotelSearchRequest><LoginInfo><UserName>service@wakanow.com</UserName><Password>password</Password></LoginInfo><Search><CityName>Dubai City</CityName><CountryName>United Arab Emirates</CountryName><CheckIn>15-12-2013</CheckIn><CheckOut>18-12-2013</CheckOut><Rooms>1</Rooms><Pax><Room><RoomId>1</RoomId><Adults No=\"2\"/><Child No=\"1\"><Age>5</Age></Child></Room></Pax><Currency>NGN</Currency><Ratings></Ratings><MinPrice></MinPrice><MaxPrice></MaxPrice><HotelName></HotelName></Search></HotelSearchRequest>";
NSLog(@"SOAP MSG : %@",sSOAPMessage);
sSOAPMessage = (NSString *) CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[sSOAPMessage mutableCopy], NULL, CFSTR(",!$'()*+;?\n\"<>#\t :/"),kCFStringEncodingUTF8));
NSString *strRequest = [NSString stringWithFormat:@"http://betahwcf.wakanow.com/SVCServices/WakanowHotelService.svc/HotelSearch=%@",sSOAPMessage];
NSURL *sRequestURL = [NSURL URLWithString:strRequest];
NSLog(@"NSURL : %@",sRequestURL);
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:sRequestURL];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
self.conWebData = [NSMutableData data];
}
else
{
NSLog(@"Some error occurred in Connection");
}
}
-(void)connection:(NSURLConnection*)connection didReceiveResponse: (NSURLResponse*)response
{
[self.conWebData setLength:0];
}
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
{
[self.conWebData appendData:data];
}
-(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
{
NSLog(@"ERROR with theConenction");
}
-(void)connectionDidFinishLoading:(NSURLConnection*)connection
{
NSLog(@"DONE. Received Bytes: %d", [self.conWebData length]);
NSString*theXML = [[NSString alloc] initWithBytes:[self.conWebData mutableBytes] length:[self.conWebData length] encoding:NSUTF8StringEncoding];
//Check That the response is in with proper Format or not
//Print Response
NSLog(@"%@",theXML);
xmlParser= [[NSXMLParser alloc]initWithData:self.conWebData];
[xmlParser setDelegate:self];
[xmlParser setShouldResolveExternalEntities:YES];
[xmlParser parse];
}