1

I am trying to connect my iphone with my local web service but the phone can't find the page on the server. It works when I test my app on xcode on the mac but it fails once I try it on the phone.

I've tried these method but it didn't work for me Accessing localhost from iPhone (in same network) Connect Device to Mac localhost Server?

    ViewController.h

    -(IBAction)Invoke:(id)sender{

        NSstring *soapformat = ....;
        //This is what i use to test it on the mac on xcode and it finds the page
        //NSURL *locationOfWebService = URLWithString:@"http://127.0.0.1:8080/Service1.asmx;

        //
        NSURL *locationOfWebService = 192.168.1.57/Service1.asmx;
        }

Output

2014-06-24 08:48:08.303 SoapServiceTest[1609:60b] The request format is <?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<printsomeThing xmlns="http://tempuri.org/">
<userData>12</userData></printsomeThing>
</soap:Body>
</soap:Envelope>
2014-06-24 08:48:08.308 SoapServiceTest[1609:60b] web url = http://192.168.1.57/Service1.asmx
2014-06-24 08:48:08.500 SoapServiceTest[1609:60b] DONE. Received Bytes: 211
2014-06-24 08:48:08.501 SoapServiceTest[1609:60b] XML <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /Service1.asmx was not found on this server.</p>
</body></html>

I've tried using my_mac_name.local/Service1.asmx as well but it still didn't work. Im pretty sure it is my locationOfWebService but im not sure how else to change it.

Community
  • 1
  • 1
Brian Xu
  • 71
  • 11

2 Answers2

0

The port number is not in the address. It looks like it should be:
NSURL *locationOfWebService = 192.168.1.57:8080/Service1.asmx;

Blake G
  • 581
  • 7
  • 24
  • yea i tried that too but it fails my didFailWithError check for some reason `-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConenction"); }` – Brian Xu Jun 24 '14 at 13:14
  • Maybe your mac's firewall is blocking the connection from external computers. What happens if you turn off the firewall? – Blake G Jun 24 '14 at 13:17
  • yea it still returns me ERROR with theConnection – Brian Xu Jun 24 '14 at 13:22
  • Yes, based on the output it is connecting to the server. Do you have any gut-feelings on why it cannot find the specific file? – Blake G Jun 24 '14 at 13:25
  • hmm im feeling maybe there is something to do with the iphone setting since when I switch it to the iOS simulator nd 127.0.0.1:8080 it works like magic – Brian Xu Jun 24 '14 at 13:30
  • This isn't my field of expertise. But since it works under an emulator, is there something about the Xcode environment where the .asmx file would not be available if you aren't running the simulator? How is the .asmx file being served? – Blake G Jun 24 '14 at 13:33
  • Im using xamarin to host my web service. Im looking around and I think i may need to generate a proxy for my web service to reach my iphone – Brian Xu Jun 24 '14 at 13:44
0

Found the problem,so turned out issue was I was using the development server to run my webservice that turns out only localhost can access. So the iphone couldnt find the pages on the web service unless they are being hosted on an iis or another type of hosting software.

Brian Xu
  • 71
  • 11