1 首先建一个WebService(这里取名为:WebServiceDemo),用来被调用。
2 在WebService中写了两个简单的[WebMethod]
其中一个类似Hello World,另一个是返回DataSet的方法,代码与以前差不多,不在写。
3 再建一个新的"智能设备应用程序"项目,取名SmartDeviceApplicationDemo
4 为这个SmartDeviceApplicationDemo添加Web引用,这里需要注意的是,引用不能使用localhost
应该使用计算机名字/IP,因为分属两个设备。例如,本项目中加引用时:
使用 http://172.16.3.60/WebServiceDemo/Demo.asmx 而不是:http://localhost/WebServiceDemo/Demo.asmx
5 在SmartDeviceApplicationDemo项目中的窗体(取名Demo)加相应的控件:textBox,button,dataGrid,label
在button的click事件中指定dataGrid的数据源应为DataTable(不知道为什么,因为DataSet,DataView不成功!)
6 部署: 因为没有Pocket PC 设备,这里选择"Pocket PC 2002 模拟器",会有相应提示。
最终的程序截图(点击完button后的效果)如下所示:
2 在WebService中写了两个简单的[WebMethod]
其中一个类似Hello World,另一个是返回DataSet的方法,代码与以前差不多,不在写。
3 再建一个新的"智能设备应用程序"项目,取名SmartDeviceApplicationDemo
4 为这个SmartDeviceApplicationDemo添加Web引用,这里需要注意的是,引用不能使用localhost
应该使用计算机名字/IP,因为分属两个设备。例如,本项目中加引用时:
使用 http://172.16.3.60/WebServiceDemo/Demo.asmx 而不是:http://localhost/WebServiceDemo/Demo.asmx
5 在SmartDeviceApplicationDemo项目中的窗体(取名Demo)加相应的控件:textBox,button,dataGrid,label
在button的click事件中指定dataGrid的数据源应为DataTable(不知道为什么,因为DataSet,DataView不成功!)
private void My_Btn_Click(object sender, System.EventArgs e)
{
WebServiceDemo.Demo d=new WebServiceDemo.Demo();
My_TxtBox.Text=d.HelloWorld("您好,比尔·盖茨").ToString();
//如何绑定DataGrid1?
DataSet ds=new DataSet();
ds=d.duty_dtail();
this.dataGrid1.DataSource=ds.Tables["duty"];
}
{
WebServiceDemo.Demo d=new WebServiceDemo.Demo();
My_TxtBox.Text=d.HelloWorld("您好,比尔·盖茨").ToString();
//如何绑定DataGrid1?
DataSet ds=new DataSet();
ds=d.duty_dtail();
this.dataGrid1.DataSource=ds.Tables["duty"];
}
6 部署: 因为没有Pocket PC 设备,这里选择"Pocket PC 2002 模拟器",会有相应提示。
最终的程序截图(点击完button后的效果)如下所示: