Uri uri = new Uri("http://localhost:6580/Service1.svc?wsdl");             MetadataExchangeClient mexClient = new MetadataExchangeClient(uri, MetadataExchangeClientMode.HttpGet);             MetadataSet metadataSet = mexClient.GetMetadata();             WsdlImporter importer = new WsdlImporter(metadataSet);             ServiceEndpointCollection endpoints = importer.ImportAllEndpoints();             foreach (ServiceEndpoint endpoint in endpoints)             {                 ContractDescription contract = endpoint.Contract;                 Console.WriteLine("Namespace:{0},Name:{1}", contract.Namespace, contract.Name);             }

CodeCompileUnit ccu = new CodeCompileUnit();             CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");             ServiceContractGenerator generator = new ServiceContractGenerator(ccu);             foreach (ContractDescription description in importer.ImportAllContracts())             {                 generator.GenerateServiceContractType(description);             }             StringWriter writer = new StringWriter();             provider.GenerateCodeFromCompileUnit(ccu, writer, null);             string code = writer.ToString();             File.WriteAllText("proxy.cs", code, Encoding.Default);

动态得到WCF的代理类并生成代码的更多相关文章

  1. 终于解决:升级至.NET 4.6.1后VS2015生成WCF客户端代理类的问题

    在Visual Studio 2015中将一个包含WCF引用的项目的targetFramework从4.5改为4.6.1的时候,VS2015会重新生成WCF客户端代理类.如果WCF引用配置中选中了&q ...

  2. Mybatis源码解析(三) —— Mapper代理类的生成

    Mybatis源码解析(三) -- Mapper代理类的生成   在本系列第一篇文章已经讲述过在Mybatis-Spring项目中,是通过 MapperFactoryBean 的 getObject( ...

  3. WCF透明代理类,动态调用,支持async/await

    我们希望WCF客户端调用采用透明代理方式,不用添加服务引用,也不用Invoke的方式,通过ChannelFactory<>动态产生通道,实现服务接口进行调用,并且支持async/await ...

  4. 动态调用WebService的代理类

    using System; using System.Collections; using System.ComponentModel; using System.Data; using System ...

  5. WCF服务代理类-学习

    类:ServiceDescriptionImporter Class 公开一种为 XML Web services 生成客户端代理类的方法. 地址:https://docs.microsoft.com ...

  6. 根据Webservice地址,动态传入参数(Webservice代理类)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sunlib; ...

  7. C#:解决WCF中服务引用 自动生成代码不全的问题。

    问题描述: 如下图:打叉的部分是引用不成功的部分 ,在web.config文件中没有自动添加其引用代码. 英文解释 在服务引用选择自己的项目的程序集就行了,如下图: 特别注意:这些程序集一定要在自己的 ...

  8. 关于IIS寄宿WCF服务,客户端不能生成代理类

    我在使用VS2010写好WCF的Web服务后,部署在IIS7.0上,可以在IE9上进行访问,并且能显示XML数据,如下图 然后我在项目的客户端进行服务的添加引用,如下图 VS2010自动生成代理类,但 ...

  9. SpringAOP-JDK 动态代理和 CGLIB 代理

    在 Spring 中 AOP 代理使用 JDK 动态代理和 CGLIB 代理来实现,默认如果目标对象是接口,则使用 JDK 动态代理,否则使用 CGLIB 来生成代理类. 1.JDK 动态代理 那么接 ...

随机推荐

  1. 【Python】Python中对象管理与垃圾回收中两个很有意思的问题

    再Python中是利用引用计数来实现对象管理和垃圾回收的,即其他对象引用该对象时候,其引用计数加1,反之减1,当引用计数为0时候,被垃圾收集器回收. Python解释器对对象以及计数器的管理分为以下两 ...

  2. jQuery中的ajax使用详解

    $.ajax({   type : "get",   url : "http://www.w3school.com.cn/jquery/ajax_ajax.asp&quo ...

  3. [河南省ACM省赛-第三届] BUYING FEED (nyoj 248)

    #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> us ...

  4. Java I/O演进与Linux网络I/O模型

    参考文章: 简书-浅谈Linux五种IO:http://www.jianshu.com/p/486b0965c296 一.linux基础概念 1.1 内存空间 linux系统中的使用的是虚拟存储器,即 ...

  5. Gentoo网络管理方法总结

    OpenRC/netifrc Netifrc is a collection of modules created to configure and manage network interfaces ...

  6. Ansible Lookup

    1.  文件内容的读取 --- - hosts: all vars: contents: "{{ lookup('file', '/etc/foo.txt') }}" tasks: ...

  7. Python爬虫----Beautiful Soup4 基础

    1. Beautiful Soup简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据.官方解释如下: Beautiful Soup提供一些简单的.pyth ...

  8. snmp协议接口

    所有网络设备上都会支持smap,获取服务器的基本信息,这样就不用在客户端上装应用就可以检测到基本的信息,是基于socket开发 内存调用这些命令来提取服务器的信息 snmpgetlocalhost - ...

  9. OvS: data structure analysis

    hmap usage: in include/openvswitch/shash.h, we have: at first glance, it is a hmap encapsulated in s ...

  10. mac下配置gdb调试golang

    mac下配置gdb调试golang 原文链接 https://sourceware.org/gdb/wiki/BuildingOnDarwin Building GDB for Darwin Crea ...