WCF generates client proxy classes and configuration files via SVCUtil.exe (GO)

Source: Internet
Author: User

WCF service calls are done in two common ways:

1: One is the way to SvcUtil.exe or add service references with the help of a code generation tool.

2: One is to make service calls directly by creating a service proxy object through ChannelFactory.

This article is intended only for the generation of proxy classes and corresponding configuration files through the SvcUtil.exe tool.

One: Generate proxy class and corresponding configuration file via cmd command line

1. Locate the following address "C:\Windows\System32\cmd.exe" command-line tool, right-run as administrator (depending on whether the system is Win7)
2. Enter the following command:

c:\>cd C:\Program Files\Microsoft Sdks\windows\v7.0a\bin
C:\Program Files\Microsoft Sdks\windows\v7.0a\bin>svcutil.exe/out:clientcode.cs
/config:\app.config http://localhost:62026/CalculatorService.svc

Description
Parameter: "C:\ClientCode.cs" refers to the address where the generated proxy class output is stored
Parameter: "C:\app.config" refers to the output storage address of the configuration file that is stored in the calling WCF Service program directory
Parameter: "Http://localhost:81/WCFServiceTest/CNPatentSearchService.svc" refers to the address of a WCF service deployed to IIS or the address of a hosted WCF service

3. After running the above command, two files will be generated in the "C: \" directory, ClientCode.cs and app. Config
(the necessary information such as the root node of the WCF service has been configured for us in C:\app.config, of course, if you can also modify some of the parameters yourself)

Two: By adding SvcUtil.exe to the VS external tool, and then calling the tools added in VS to generate

1: Add Svcutil tool in VS2015

1): In the VS2015 Tools menu, select External Tools , such as

2): In the pop-up window, click Add , as

3): Enter the SvcUtilin the title Bar, the command bar selects the directory where the SvcUtil.exe is located, the initial directory bar selects the generated client code and the directory that the configuration file is placed in.

Select the prompt to enter the parameters , uncheck on exit when Close , click OK to complete the Add.

2: When added, click SvcUtilunder the VS2015 Tools menu, as

In the parameters Bar, enter the URL of the service endpoint that provides the metadata, as

Click OK to display the success and related information on the command line that pops up. Such as

    If successful, two files are generated, one is the CS file that contains the server-side contract and the local proxy class that corresponds to the server service, and one is the WCF configuration file.
    Copy these two files to your project and rename output.config to App. Config.

Reference article:

Http://blog.163.com/[email protected]/blog/static/3743053820132133616282/

Http://www.cnblogs.com/luowanli/archive/2012/02/24/markeluo_wcfiis.html

Http://www.cnblogs.com/zfanlong1314/archive/2012/03/23/2413122.html

WCF generates client proxy classes and configuration files via SVCUtil.exe (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.