PDA(Windows Mobile)调用远程WebService
来源:互联网 发布:python函数嵌套定义 编辑:程序博客网 时间:2024/05/01 06:51
之前用模拟器测试过调用远程的WebService,发现总是提示“无法连接到远程服务器”的错误,不管是Windows Mobile6.0 还是6.5都是一样,按照网上的办法,改注册表,修改PDA的配置,安装虚拟网卡,我一一试了一遍,
都没有解决,可能是模拟器需要什么特殊的配置吧,晚一点继续摸索一下,现在先使用真机来测试一下。
1.首先新建测试的WebService服务,并将其发布在IIS或者服务器上面,我这里做了两个测试,一个是发布到本地IIS里面,一个是发布到服务器上面。
以下是我建立的两个测试Web服务。
using System;using System.Collections.Generic;using System.Web;using System.Web.Services;/// <summary>///WebService 的摘要说明/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class WebService : System.Web.Services.WebService{ public WebService() { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public string GetString(string Num1,string Num2) { return (Convert.ToInt32(Num1) + Convert.ToInt32(Num2)).ToString(); } }/// <summary>///WebServices 的摘要说明/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 // [System.Web.Script.Services.ScriptService]//public class WebServices : System.Web.Services.WebService public class WebServices : DBHelper{ public WebServices() { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod(Description = "检查用户是否存在")] public bool CheckUserExists(string UserName) { bool result = false; string strSql = "SELECT COUNT(*) FROM SYS_UserInfo WHERE UserName='" + UserName + "'"; int i = Convert.ToInt32(base.GetScalar(strSql).ToString()); if (i > 0) { result = true; } return result; }}
这里就省略掉发布的过程了,先说一下新建智能设备程序的步骤:
1.新建项目--智能设备--智能设备项目--设置项目名称以及解决方案名称--确定
2.选择目标平台,这里有 Pokcet PC,Windows CE,Windows Mobile 5.0 SDK,Windows Mobile 6.0 SDK。具体的还要看
PC上面安装了哪些SDK。
3.选择.Net Compact FrameWork 版本,2.0/3.0等等。
4.选择项目模板,表示新建的项目是控制台程序还是引用程序或者是类库等等。
现在要做的就是在程序里面调用了,先将我们的WebService引用到项目中来,
项目--右键--添加Web引用--输入服务器IP,如果是本地的话直接点击“本地计算机上面的Web服务”--自己给它命名
并点击“添加引用”按钮,
操作成功之后可以在Web References里面看到我们的WebService了,
private void button1_Click(object sender, EventArgs e) { WebReference.WebServices wbs = new PPCWebS.WebReference.WebServices();//服务器上面的WebService bool result = wbs.CheckUserExists(this.txtServerValue.Text.Trim()); if (result) { MessageBox.Show("用户:" + this.txtServerValue.Text.Trim() + "存在数据库中"); } else { MessageBox.Show("用户:" + this.txtServerValue.Text.Trim() + "不存在数据库中"); } } private void button3_Click(object sender, EventArgs e) { WebReference2.WebService w = new PPCWebS.WebReference2.WebService();//本地IIS里面的WebService string Result = w.GetString(this.txtLocalhost1.Text.Trim(), this.txtLocalhost2.Text.Trim()); MessageBox.Show(this.txtLocalhost1.Text.Trim() + "+" + this.txtLocalhost2.Text.Trim() + "=" + Result); }
小技巧:通过 Windows CE Remote Zoom-in(远程放大)可以捕获到智能设备的屏幕
开发的环境:IIS V5.1
Visual Studio 2008专业版
Windows Mobile 6.1 智能设备
Windows Mobile 6.0 SDK
- PDA(Windows Mobile)调用远程WebService
- Mobile动态调用webservice
- PDA动态调用JAVA提供的WebService
- windows mobile 访问webservice
- Windows Mobile PDA、手机、智能终端开发培训
- (windows mobile) PDA/PPC下如何获取GPRS的网络流量
- 如何屏蔽windows mobile手机按键 pda手机键盘钩子/HOOK
- Windows Mobile系统PDA进行GPS导航的入门知识
- C# Mobile远程调用WebService时,返回DataTable出现隐式转换出问题的解决方案
- 远程调用WebService
- WebService的远程调用
- 远程调用webservice
- c++远程调用webservice
- webservice远程调用详解
- axis2远程调用webservice
- webservice远程调用方法
- WebService远程调用技术
- Windows Mobile中的WebService应用
- JAVA中的四个内部类-成员内部类,静态内部类,方法内部类,匿名内部类
- Uva 11584 - Partitioning by Palindromes dp
- makefile 文件样例
- 三星S24A350型显示器黑屏解决方法
- 联想五道笔试题 答案
- PDA(Windows Mobile)调用远程WebService
- 关于Server Tomcat v8.0 Server at localhost failed to start的解决办法
- 重新开始
- 蒋介石的故乡-浙江奉化溪口
- python json 序列化反序列化 和 中文编码问题
- UIButton的使用细节
- 机器学习之&&Andrew Ng课程复习--- 神经网络的表层结构2
- linux下cat命令详解
- linux GB2312转UTF-8 shell脚本