坚持svc web服务请求无法到达服务器

时间:2013-11-12 14:14:20

标签: ios wcf svc

我从iOS代码调用这个web服务但是当我在iOS代码中调用同一个请求时,它没有给我回复。收到的致命错误或响应字节0。

我在从iOS代码发布时检查服务器,但原因是我的请求无法在服务器上成功访问。

任何人都可以知道为什么我的请求无法到达服务器吗?

1 个答案:

答案 0 :(得分:2)

  • 这是我的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];
     }