Usage of WCF svcutil

Source: Internet
Author: User

[转]

WCF中可以使用SVCUtil.exe生成客户端代理类和配置文件

        1.找到如下地址“C:\Windows\System32\cmd.exe”  命令行工具,右键以管理员身份运行(视系统是否为win7 而定) 
        2.输入如下命令:

C:\>cd C:\Program Files\Microsoft SDKs\Windows\v7.0A\binC:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>SvcUtil.exe /out:clientCode.cs /config:\app.config http://localhost:62026/CalculatorService.svc

 说明:
              参数:  “C:\ClientCode.cs ”   ,是指生成的代理类输出存放到的地址
              参数:  “C:\app.config ”   ,是指存放到调用WCF服务程序目录下的配置文件的输出存放地址
              参数:  “http://localhost:81/WCFServiceTest/CNPatentSearchService.svc”   ,是指部署到IIS 的WCF服务的地址
              
            3.运行以上命令后,会在"C:\"目录下生成两个文件,ClientCode.cs  和app.config
          (C:\app.config 中已经为我们配置好了WCF服务的根节点等必须的信息,当然,如果您也可以自己对部分参数进行修改)

在Vs2010添加Svcutil工具

    在VS2010的 Tools菜单中选择External Tools,如 

 点击添加按钮,在Title栏输入SvcUtil,Command栏选择SvcUtil.exe所在的目录,Initial directory栏选择生成的客户端代码和配置文件所放的目录,

选上Prompt for arguments,不选上Close on exit,点击OK完成添加。

    添加好以后,点击VS2010菜单下的SvcUtil,输入提供元数据的服务终结点的 URL,如

点击OK,在弹出的命令行中会显示成功与否和相关信息。如

 

wcf Svcutil用法

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.