无法在iPhone上找到本地Web服务的页面。

19 浏览
0 Comments

无法在iPhone上找到本地Web服务的页面。

我正在尝试将我的iPhone连接到本地的Web服务,但是手机无法在服务器上找到页面。当我在Mac上使用Xcode测试我的应用时,它可以正常工作,但是一旦我在手机上尝试,就会失败。\n我尝试了下面的方法,但对我没有起作用:\nAccessing localhost from iPhone (in same network)\nConnect Device to Mac localhost Server?\n

    ViewController.h
    -(IBAction)Invoke:(id)sender{
        NSstring *soapformat = ....;
        //这是我在Mac上使用Xcode测试时使用的,它可以找到页面
        //NSURL *locationOfWebService = URLWithString:@"http://127.0.0.1:8080/Service1.asmx;
        //
        NSURL *locationOfWebService = 192.168.1.57/Service1.asmx;
        }

\n输出:\n

2014-06-24 08:48:08.303 SoapServiceTest[1609:60b] 请求格式为 



12


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] 完成。接收到的字节数:211
2014-06-24 08:48:08.501 SoapServiceTest[1609:60b] XML 

404 Not Found

Not Found

The requested URL /Service1.asmx was not found on this server.

\n我还尝试使用my_mac_name.local/Service1.asmx,但仍然没有起作用。我很确定问题出在locationOfWebService上,但是不知道如何进行其他更改。

0
0 Comments

问题原因:

问题出现的原因是使用开发服务器来运行web服务,结果只有localhost可以访问。因此,iPhone无法找到web服务上的页面,除非它们被托管在IIS或其他类型的托管软件上。

解决方法:

要解决这个问题,需要将web服务托管在IIS或其他类型的托管软件上,以便iPhone可以找到页面。

0
0 Comments

在iPhone上找不到本地网络服务页面的原因可能是端口号未包含在地址中。解决方法可能是将端口号添加到地址中:NSURL *locationOfWebService = 192.168.1.57:8080/Service1.asmx;

另一个可能的解决方法是关闭Mac的防火墙,看看是否可以建立连接。如果仍然返回错误信息,可能是iPhone的设置有问题。

根据对话中的输出信息,连接是成功的,但无法找到特定的文件。可能是因为在Xcode环境中,如果不运行模拟器,.asmx文件将无法使用。

使用Xamarin主机来托管web服务,可能需要为web服务生成代理以便让iPhone访问。

0