本篇简要说明

windows mobile上的应用程序除了可以与本地的SQL Server CE进行数据交互,还可以与远程的webservice通信,这个过程基本类似于winform的开发,我们可以先建立一个解决方案,包括一个windows mobile的应用程序项目和一个web网站,其中web网站内只需要添加一个webservice服务页面即可,这里按默认的页面,这个服务内部只有一个默认方法Helloworld,当windows mobile应用程序调用此方法时,可以接收到hello,world!

步骤一 建立webservice及windows mobile 应用程序

werservice内只有一个简单方法helloworld();

windows mobile移动应用程序与webservice之间的数据交互

步骤二 在windows mobile应用程序中添加web引用,引用名默认

windows mobile移动应用程序与webservice之间的数据交互

添加引用后,在默认的Form1上添加一个按钮,用来触发webservice事件,可以在按钮的点击事件添加如下调用代码:

private void button1_Click(object sender, EventArgs e)
        {
            localhost.Service ws = new SmartDeviceProject1.localhost.Service();
            MessageBox.Show("Message From webservice: "+ws.HelloWorld());
        }

这样即可测试了,但是这里有一个问题,就是在搜索资料时发现webcast中的代码,webservice的地址不是:

http://localhost:4534/WebSite2/WebService.asmx

 

就是说这个webservice地址的采用的是PC的名称,不是localhost,而应该填写本机的内网ip:端口号,比如http://192.168.1.6:3900//路径.....。

 相关源码:本机windows mobile下windows mobile+webservice-1和windows mobile+webservice-2

原文链接:http://www.cnblogs.com/wengyuli/archive/2010/04/17/windows-mobile-webservice.html

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2021-08-23
  • 2022-02-12
  • 2022-12-23
  • 2021-07-26
相关资源
相似解决方案