初学wcf,遇到一些问题:我的客户端和服务器在不同的电脑上开发,那么客户端如何添加服务端的引用,是不是只能通过配置文件?如果通过配置文件的话,又怎么添加服务端实体类的引用?请高手们不吝赐教!!!wcf

解决方案 »

  1.   

    配置文件,自己写代码也可以。
    个人觉得要用实体类,拷贝到客户端添加dll用吧。
      

  2.   

    可以使用Svcutil.exe生成Web服务和WCF服务的客户端代理接口及配置文件也就是说只要你服务端写好了程序,可以直接生产客户端wcf配置文件如下,使用svcutil.exe指令 svcutil.exe [/n:] /out:D:\>svcutil /n:http://eric.org,eric.org http://127.0.0.1:8988/calculatorservice/metadata /out:d:\client.cs
    Microsoft (R) Service Model Metadata Tool[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]Copyright (c) Microsoft Corporation.  All rights reserved.Attempting to download metadata from 'http://127.0.0.1:8988/calculatorservice/metadata' using WS-Metadata Exchange or DISCO.Generating files...d:\client.csD:\output.config+++++++++++++++指令解释++++++++++++++++++++++++++++++++++++1) /n /namespace:         - A mapping from a WSDL or XML Schema targetNamespace to a CLR namespace. Using the '*' for the targetNamespace maps all targetNamespaces without an explicit mapping to that CLR namespace. Default: derived from the target namespace of the schema document for Data Contracts. The default namespace is used for all other generated types. (Short Form: /n)2) url读取WSDL服务定义的链接3)/out:输出文件的路径文件名。