无法从移动模拟器访问Web服务 [英] Cannot access web service from mobile emulator

查看:66
本文介绍了无法从移动模拟器访问Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在做一个有关Web服务的项目,该项目可以通过Windows手机应用程序进行访问.
添加引用后尝试访问Web服务时,出现错误,提示我无法连接到服务器

有人可以帮我吗?

Hi,

I am doing a project on web serivces which will be accessed through windows mobile phone application.
When I try to access the web service after adding the reference, I get error that I was unable to connect to server

Can anyone help me on this?

推荐答案

Hello Gaurish,

我在工作中遇到了同样的问题.

问题之一是服务和客户端的配置文件.确保服务配置中的Web协议与客户端配置协议匹配. Windows Phone 7不适用于wsHttpBinding.因此,您可能需要使用basicHttpBinding.

另外,一旦添加了服务参考,最好立即构建项目.我发现VS2010并不总是生成References.cs的代码.如果单击解决方案资源管理器上的显示所有文件"按钮,然后导航到References.cs文件,可以看到生成的代码吗?

如果所有其他方法均失败,请遵循本教程:使用WCF服务创建使用数据的Windows Phone 7应用程序由Urmimala Pal.完成项目后,请研究服务和配置文件以及References.cs文件.教程项目和您自己的项目之间有什么区别?将这些差异应用于您自己的项目是否可行?

部署到物理设备时的问题是,如果您在本地网络上放置Web服务,则Windows Phone无法使用该服务.但是,如果您可以通过Internet访问Web服务,那么在进行实时测试时连接就不会有问题.

我遇到的主要问题归结为配置文件配置不正确.这可能是您遇到的问题.尝试删除服务引用和客户端配置文件,然后重试.

希望这些信息对您有所帮助.

亲切的问候,

杰森.
Hello Gaurish,

I have had this same issue at work.

One of the issues is with the config files for the service and the client. Make sure that the web protocols in the service config match with the client config protocols. Windows Phone 7 does not work with the wsHttpBinding. So you will probably want to use the basicHttpBinding.

Also, once you have added a service reference, it is best to build the project straight away. I have found that VS2010 doesn''t always generate the code for References.cs. If you click on the show all files button on the solution explorer, and then navigate to the References.cs file, can you see the generated code?

If all else fails, follow this tutorial: Creating a Windows Phone 7 Application consuming data using a WCF Service by Urmimala Pal. Once you have got the project working, study the service and config files, and References.cs file. What are the differences between the tutorial project and your own project? Does applying these differences to your own project work?

The problem when deploying to a physical device is that if you house a web service on your local network, it is unavailable to the windows phone. However, if you make your web service accessible over the internet then you should have no problem connecting when you come to do a live test.

The main problems I experienced were down to the configuration files being incorrectly configured. This may be the problem you are experiencing. Try deleting your service references and client config file and try again.

I hope this information will be helpful.

Kind Regards,

Jason.


这篇关于无法从移动模拟器访问Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆