Generate client code and configuration through svcutil.exe

Source: Internet
Author: User

Two common methods are used to call a WCF Service: one is to use the code generation tool svcutil.exe or add a service reference. The other is to directly create a service proxy object through ChannelFactory for service calling.

To put it simply, how does one call the service through svcutil.exe:

SvcUtil.exe is a command line tool located in the C: \ Program Files \ Microsoft SDKs \ Windows \ v7.0A \ bindirectory. You can add SvcUtil.exe to VS2010 to facilitate future use: select External Tools from the Tools menu of VS2010, as shown in figure

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click "Export" and enter svcutilin the titlefield. In the commandbar, select the directory where svcutil.exe is located. In the Initial directory column, select the generated client code and directory of the configuration file, select Prompt for arguments, Close on exit, and click "OK.

After adding the metadata, click SvcUtil in the VS2010 menu and enter the URL of the service endpoint that provides metadata, as shown in figure

Click OK. The displayed command line displays the success or failure information and related information. For example

If successful, two files will be generated. One is the cs file that contains the Contract on the server and the local proxy class corresponding to the service on the server, and the other is the WCF configuration file, copy the two files to the project and copy the output. config is changed to app. config.

For more commands on SvcUtil, see MSDN: http://msdn.microsoft.com/zh-cn/library/aa347733%28VS.90%29.aspx

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.