首页 > 其他 > 详细

WCf客户端测试

时间:2014-03-16 22:52:33      阅读:633      评论:0      收藏:0      [点我收藏+]
  1. 添加项目ConsoleWCFTest
  2. 添加WCFService、WCFServiceProxy
  3. 配置App.config
    bubuko.com,布布扣
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
    
      <system.serviceModel>
        <client>
          <endpoint name="bookInfo1" address="net.tcp://localhost:8082/BookService" binding="netTcpBinding"
                    contract="WCFService.IBookService" >
          </endpoint>
          <endpoint name="bookInfo" address="http://localhost:8081/service/basic" binding="basicHttpBinding" contract="WCFService.IBookService">
          </endpoint>
        </client>
      </system.serviceModel>
    </configuration>
    bubuko.com,布布扣

     

  4. 调用
    bubuko.com,布布扣
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using WCFService.Models;
    using WCFServiceProxy;
    
    namespace ConsoleWCFTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                var result = BookServiceProxy.Add("WCF编程", 12);
                List<Book> list = BookServiceProxy.GetList();
                Console.WriteLine("Add:" + result);
                Console.WriteLine("GetList:" + list);
                Console.ReadLine();
            }
        }
    }
    bubuko.com,布布扣

     

WCf客户端测试,布布扣,bubuko.com

WCf客户端测试

原文:http://www.cnblogs.com/wzq806341010/p/3603654.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!