客运综合管理系统项目(1) 搭建WCF框架

     使用VS2010 版本搭建WCF框架

1.1 新建WCF项目应用程序(BLL

(1)第一步,打开Vs界面,点击左上角文件,点击新建,选择项目

                                                                                                                                      1.1 (图1

(2)第二步,如图1.1(图2),点击WCF类型,选择WCF服务应用程序应用程序,在名称中输入项目名称(解决方案名称),位置可自行选择存放该项目的路径,完成后点击确定,得到图3的界面

                                                                                                                                       

 

                                                                                                                                           1.1 (图2)

                                                                                                                                  1.1 (图3)

1.2 新建类库和类(BLL

(1)第一步,如图1.2(图1),右击解决方案,移动鼠标到添加,再到新建项目,从而实现添加一个类库


                                                                                                                             1.2(图1)

(2)第二步,如图1.2(图2),新建一个类库,在名称中输入项目名称(解决方案名称),位置可自行选择存放该项目的路径,完成后点击确定


                                                                                                                            1.2(图2)

(3)第三步,第二步确定后得到 1.2(图3)显示的界面,里面生成了一个类,右击类名进行更改名称


                                                                                                                                          1.2(图3)

(3)第四步,添加多一个类,总体操作和第一步差不多

 

                                                                                                                              1.2(图4)


                                                                                                                           1.2(图5)

(3)可以先新建一个文件夹,再添加类,这样可以将不同模块的类分开,具体操作如图6,得到结果如图7


                                                                                                                                 1.2(图6)


                                                                                                                        1.2(图7)

1.3  新建数据层(BLL

(1)第一步,和1.2中【(4)第四步】添加一个类一样添加一个类。第二步,如图 1.3(图1); 【1.3(图2)是连接数据库的一些代码】

                                                                                                                                           1.3(图1)


                                                                                                                                       1.3(图2)

1.4  新建窗体(UIL

(1)第一步,1.如图1.4(图1),创建一个windows窗体应用程序;


                                                                                                                                    1.4(图1)

            2.1.4(图2)是创建后的界面,左面是一个窗体,右面是解决方案的基本样式,右击右面的form1.cs可以修改它的名称,


                                                                                                                              1.4(图2)

(2)第二步,如图1.4(图3),可以添加一个窗体,也可以如图1.2(图6)一样,先创建一个文件夹,再创建窗体


                                                                                                                                   1.4(图3)

(3)如图1.4(图4),新建一个窗体


                                                                                                                       1.4(图4)

1.5 不同层的相互联系

(1)如图 1.5(图1),服务端(BLL)相互联系


                                                                                                                                         1.5(图1)

(2)如图 1.5(图2),服务端(BLL)中不带箭头的给带箭头的引用


                                                                                                                                          1.5(图2)

1.6 配置服务

【1】服务端(BLL)

(1)右击引用进行添加引用


                                                                                                                                       1.6(图1)

(2)按添加引用出现图 1.6(图2)的界面,按图片提示执行


                                                                                                                                               1.6(图2)

(3)如图  1.6(图3),重新生成解决方案


                                                                                                                                  1.6(图3)

(4)按图1.6(图4)操作即可


                                                                                                                            1.6(图4)

(5)按图1.6(图5)操作


                                                                                                                                        1.6(图5)

(6)按图1.6(图6)操作,右击后点击编制WCF配置


                                                                                                                                1.6(图6)

(7)如图1.6(图7)所示,在配置服务器中执行以下操作,即新建服务


                                                                                                                          1.6(图7)

(8)如图1.6(图8)所示,进到这个页面后点击浏览


                                                                                                                      1.6(图8)

(9)如图1.6(图9)所示,进到这个页面后点击bin


                                                                                                          1.6(图9)

(10)如图1.6(图10)所示,进到这个页面后选择逻辑层,点击进去


                                                                                                                         1.6(图10)

(11)如图1.6(图11)所示,选择一个新添加的类型名称进行操作


                                                                                                           1.6(图11)

(12)如图1.6(图12)所示,按下一步


                                                                     1.6(图12)

(13)如图1.6(图13)所示,按下一步


                                                                         1.6(图13)

(14)如图1.6(图14)所示,按下一步


                                                                                             1.6(图14)

(15)如图1.6(图15)1.6(图16)所示,按下一步


                                                                                             1.6(图15)

(16)删除地址,再按下一步


                                                                        1.6(图16)


                                                                                    1.6(图17)

(16)如图1.6(图18)所示,点击是


                                                                                                            1.6(图18)

(17)如图1.6(图19)所示,点击完成


                                                                                                 1.6(图19)

(18)如图1.6(图20)所示,高级--》服务行为--》空名称,填写项目名称



                                                                                                             1.6(图20)

19)图1.6(图21)右边要对应


                                                                                                1.6(图21)

(20)图1.6(图22)右边要对应


                                                                                                         1.6(图22)


(21)如图1.6(图23)所示,服务--》项目名称--》终结点--》空名称,图右边填写名称


                                                                                                   1.6(图23)

(22)如图1.6(图24)所示,点击项目名称,再选择里面的名称


                                                                                       1.6(图24)

(23)如图1.6(图25)所示,复制待用


                                                                                                                       1.6(图25)

(24)按图1.6(图26)操作


                                                                                                                 1.6(图26)

(25)按图1.6(图27)操作


                                                                                                       1.6(图27)

(25)按图1.6(图28)操作


                                                                                        1.6(图28)

(26)如图1.6(图29)所示,保存退出


                                                                                                       1.6(图29)

(27)如图1.6(图30)所示,执行程序


                                                                                                                           1.6(图30)

(28)如图1.6(图31)所示,跳转的浏览器的界面,在地址里黏贴刚才复制的数据,再按回车键,然后复制整个地址


                                                                                                                     1.6(图31)

【2】客户端(UIL)

 (29)如图1.6(图32)所示,客户端引用服务


                                                                                                         1.6(图32)

(30)如图1.6(图32)所示,按步骤操作


                                                                                                                               1.6(图33)

(31)如图1.6(图34)所示,完成了一个配置


                                                                                                        1.6(图34)


文字描述

1.BLL添加引用(ServiceModel)

2.添加using ServiceModel

3.类前添加  [ServiceContract] 标签(服务契约)添加在类的前面

4.每一个方法前添加  [OperationContract]标签(行为契约)添加在方法的前面

5.修改DataTable类型为DataSet(修改方法返回值类型)

   DataTable dt=**********;

   DataSet ds=new DataSet ();

   ds.Tables.Add(dt);

   return ds;

6.保存并重新生成

7.打开工具 WCF服务配置编辑器,关闭 WCF服务配置编辑器

8.在web.config文件上右键打开WCF配置工具

 

 

9.新建服务,浏览——》上一层——》BLL——》bin——》debuge——》****.dll——》打开

10.复制名字   BLL库存管理.frmYaoPinWeiHu

11.下一步——》下一步——》下一步——》下一步——》删除地址——》是——》下一步——》完成

12.服务——》终结点——》空名称——》name——》粘贴

13.高级——》服务行为——》name——》BLL库存管理

14.servicemetadata——》True False Delaft   servicedebug——》True True True

15.服务——》指定服务行为

16.高级——》宿主环境——》服务激活——》新建——》第一项指定地址*****.svc 第二项指定服务

17.保存并关闭

客户端配置步骤:

1.运行服务端

2.复制服务端地址(要使用的服务的地址)

3.添加 服务引用

4.输入网址,点击前往,修改命名空间(命名空间的名字)

5.修改UIL接受BLL方法,********()+.Tables[0]

6.在启动项中添加非启动项的全部服务引用。

如果服务端有没有打的,在服务端添加完之后在客户端右键更新服务引用。




仅供学习,禁止用于商业用途





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值