zoukankan      html  css  js  c++  java
  • How to: Create a Windows Communication Foundation Client

    How to: Create a Windows Communication Foundation Client

    To create a Windows Communication Foundation client

    1. Create a new console application project by right-clicking on the Getting Started solution, selecting, Add, New Project. In the Add New Project dialog on the left hand side of the dialog select Windows under C# or VB. In the center section of the dialog select Console Application. Name the project GettingStartedClient.

    2. Set the target framework of the GettingStartedClient project to .NET Framework 4.5 by right clicking on GettingStartedClient in the Solution Explorer and selecting Properties. In the dropdown box labeled Target Framework select .NET Framework 4.5. Setting the target framework for a VB project is a little different, in the GettingStartedClient project properties dialog, click the Compile tab on the left-hand side of the screen, and then click the Advanced Compile Options button at the lower left-hand corner of the dialog. Then select .NET Framework 4.5 in the dropdown box labeled Target Framework.

      Setting the target framework will cause Visual Studio 2011 to reload the solution, press OK when prompted.

    3. Add a reference to System.ServiceModel to the GettingStartedClient project by right-clicking the Reference folder under the GettingStartedClient project in Solution Explorer and select Add Reference. In the Add Referencedialog select Framework on the left-hand side of the dialog. In the Search Assemblies textbox, type in System.ServiceModel. In the center section of the dialog select System.ServiceModel, click the Add button, and click the Close button. Save the solution by clicking the Save All button below the main menu.

    4. Next you wlll add a service reference to the Calculator Service. Before you can do that, you must start up the GettingStartedHost console application. Once the host is running you can right click the References folder under the GettingStartedClient project in the Solution Explorer and select Add Service Reference and type in the following URL in the address box of the Add Service Reference dialog: http://localhost:8000/ServiceModelSamples/Service and click the Go button. The CalculatorService should then be displayed in the Services list box, Double click CalculatorService and it will expand and show the service contracts implemented by the service. Leave the default namespace as is and click the OK button.

    When you add a reference to a service using Visual Studio a new item will appear in the Solution Explorer under the Service References folder under the GettingStartedClient project. If you use the ServiceModel Metadata Utility Tool (Svcutil.exe) tool a source code file and app.config file will be generated.

    You can also use the command-line tool ServiceModel Metadata Utility Tool (Svcutil.exe) with the appropriate switches to create the client code. The following example generates a code file and a configuration file for the service. The first example shows how to generate the proxy in VB and the second shows how to generated the proxy in C#:

    You have now created the proxy that the client application will use to call the calculator service. Proceed to the next topic in the series: How to: Configure a Basic Windows Communication Foundation Client

    How to: Configure a Basic Windows Communication Foundation Client

    How to: Use a Windows Communication Foundation Client

  • 相关阅读:
    手机号码正则,座机正则,400正则
    Win10 开始运行不保存历史记录原因和解决方法
    Ubuntu 普通用户无法启动Google chrome
    在win10 64位系统安装 lxml (Python 3.5)
    SecureCRT窗口输出代码关键字高亮设置
    【转】win2008 中iis7设置404页面但返回状态200的问题解决办法
    ionic app开发遇到的问题
    Ubuntu 创建文件夹快捷方式
    Ubuntu配置PATH环境变量
    Ubuntu 升级python到3.7
  • 原文地址:https://www.cnblogs.com/chucklu/p/4633368.html
Copyright © 2011-2022 走看看