wince与WCF的结合应用(VS2008 VB.Net)

1、安装WM SDK、安装NETCFv35PowerToys(需要用到里面的命令行工具以生成Wince项目所需要的wcf类库)

2、创建解决方案,项目一WINCE程序,项目二WCF服务应用程序(IIS的)

3、WCF类库的生成方法

NetCFSvcUtil.exe http://localhost:23693/Service1.svc?wsdl  /language:VB  /out:WCEWCF.vb  /cfClientBase:CFClientBase.vb

4、部署WInce程序到WM模拟器,其中的终结点地址要替换,不能是Localhost。因为程序已经在模拟器中运行,不是在本机了。

[替换代码一:使用默认的绑定]

Function CreateClientProxy() As Service1Client
        Dim binding As ServiceModel.Channels.Binding = Service1Client.CreateDefaultBinding
        Dim remoteAddress As String = Service1Client.EndpointAddress.Uri.ToString   '原终结点地址
        remoteAddress = ReadXML("IIServer")                        '替换为新的终结点地址
        Dim endpoint As EndpointAddress = New EndpointAddress(remoteAddress)
        Dim client As Service1Client = New Service1Client(binding, endpoint)
        Return client
End Function

[替换代码二:自定义绑定]

Public Function CreateClientProxy() As Service1Client

        Dim binding As New ServiceModel.BasicHttpBinding

        binding.MaxReceivedMessageSize = 2147483647

        binding.MaxBufferPoolSize = 2147483647

        binding.MaxBufferSize = 2147483647

        Dim remoteAddress As String = Service1Client.EndpointAddress.Uri.ToString

        remoteAddress = ReadXML("WCFURL")

        Dim endpoint As EndpointAddress = New EndpointAddress(remoteAddress)

        Dim client As Service1Client = New Service1Client(binding, endpoint)

        Return client

End Function

5、部署WCF程序时,若服务器已经安装过Net3.5。最好运行几个命令如下:

aspnet_regiis -i                     //安装aspnet到IIS

ServiceModelReg.exe //x            //注册WCF组件

ServiceModelReg.exe /s:W3SVC         //安装WEB主机脚本映射,其中W3SVC可替换

最后重启IIS。

运行后若发生 Error: Failed to access IIS metabase错误,则运行:

aspnet_regiis -ga ASPNET

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值