wcf第4步之原生调用简单封装
public interface IDemoServiceChannel : IDemoService, System.ServiceModel.IClientChannel {
}
public partial class DemoServiceClient : System.ServiceModel.ClientBase<IDemoService>, IDemoService {
public DemoServiceClient() {
}
public DemoServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public DemoServiceClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public DemoServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public DemoServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
public SomeResp DoSomething(SomeReq request) {
return base.Channel.DoSomething(request);
}
}
配置文件添加
<?xml version="1.0" encoding="utf-8"?>
<configuration> <system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDemoService" sendTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://dev.xxx.io/Demo/DemoService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDemoService"
contract="RestClientTest.IDemoService" name="BasicHttpBinding_IDemoService" />
</client>
</system.serviceModel>
</configuration>
调用代码更加简单
IDemoService demoService = new DemoServiceClient();
var r1 = demoService.DoSomething(new SomeReq() { Date = DateTime.Now, DateUTC = DateTimeOffset.Now });
Console.WriteLine(r1.ResultDate);
Console.Read();
wcf第4步之原生调用简单封装的更多相关文章
- Nuget调用简单封装.
1. 项目引用Dapper作为直接访问, 为了使用方便, 封装一下.达到效果: - 数据库连接配置在webconfig.xml中. - 常用调用方法封装. 调用: //可以采用单例模式. //全局实 ...
- wcf第3步之报文分析及原生调用
最简单的调用当然是服务引用,但是我更想原生调用,所以希望能通过报文有如下研究 1.报文分析 <wsdl:definitions xmlns:wsdl="http://schemas.x ...
- 使用原生ajax及其简单封装
原生ajax配置详解 // 原生ajax // 1. 创建ajax对象 if(window.XMLHttpRequest){ // // IE7+, Firefox, Chrome, Opera, S ...
- WCF技术剖析之十:调用WCF服务的客户端应该如何进行异常处理
原文:WCF技术剖析之十:调用WCF服务的客户端应该如何进行异常处理 在前面一片文章(服务代理不能得到及时关闭会有什么后果?)中,我们谈到及时关闭服务代理(Service Proxy)在一个高并发环境 ...
- Django入门第一步:构建一个简单的Django项目
Django入门第一步:构建一个简单的Django项目 1.简介 Django是一个功能完备的Python Web框架,可用于构建复杂的Web应用程序.在本文中,将通过示例跳入并学习Django.您将 ...
- ServiceStack Web Service 创建与调用简单示列
目录 ServiceStack 概念 ServiceStack Web Service 创建与调用简单示列 上篇文章介绍了ServiceStack是什么,本章进入主题,如何快速简单的搭建Service ...
- 前言:JNI调用-简单使用
JNI JNI是(Java Native Interface 本地接口)是一个协议,用来沟通Java 代码和C/C++代码,是 Java和 C.C++之间的桥梁. 通过JNI协议,Java可以调用外 ...
- Vue——项目中接口返回值为函数回调,回调函数定义方法(Vue的方法给原生调用)
在接口调用中,有时会返回给我们一个函数回调,来自动执行我们在前端定义好的某个函数(多出现于通过回调的方式传递某个数值).在原生项目中,我们只要提供一下这个方法就好了,通过函数回调会自动执行.问题就出现 ...
- iOS开发——UI篇OC篇&UITableView简单封装
UITableView简单封装 UITableView时iOS开发中使用最多也是最重的一个UI空间,其实在App Store里面的%80以上的应用都用到了这个控件,所以就给大家介绍一下,前面的文章中也 ...
随机推荐
- Hadoop Cluster 安装
本篇源自Hadoop官网,先将中文翻译如下. 目标 本文章主要是描述如何安装和配置几个节点的Hadoop clusters,甚至于数以千计的节点数.为了了解详细的安装步骤,需要先了解如何安装在单台机器 ...
- css工具收集
收集一些css的生成工具,开发中可以直接拿过来用.特别是那些css3中的一些新的特性. 1 css渐变背景在线生成工具 http://www.colorzilla.com/gradient ...
- JQuery记住用户名和密码的具体实现
代码如下: //初始化页面时验证是否记住了密码 $(document).ready(function() { if ($.cookie("rmbUser") == "tr ...
- Release Management 安装 之 集成TFS
集成TFS时需要在TFS服务器执行 tfssecurity /g+ "Team Foundation Service Accounts" n:ALM\rmtfsint ALLOW ...
- [转]17个新手常见Python运行时错误
原址:http://www.oschina.net/question/89964_62779?p=1 当初学 Python 时,想要弄懂 Python 的错误信息的含义可能有点复杂.这里列出了常见的的 ...
- POJ 1325 Machine Schedule——S.B.S.
Machine Schedule Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13731 Accepted: 5873 ...
- Let it go.Let it be.Keep it up!
第三份工作仅仅持续了三个月,今天是last day. 虽然时间很短,但也是经历一场,认识了一些人,知道了一些事. 来去匆匆,难免有一点遗憾,还有一点愧疚. 只能放下,顺其自然,继续努力!
- 使用using释放资源
using关键字 using 关键字可以用来导命名空间,与java中的import类似. 我使用using的地方 using(SqlConnection con=new SplConnection(c ...
- Error:Execution failed for task ':app:transformClassesWithDexForDebug'解决记录
转载请标明出处: http://blog.csdn.net/lxk_1993/article/details/50511172 本文出自:[lxk_1993的博客]: 3个错误non-zero e ...
- bash/shell编程学习(2)
先来复习上节重定向的用法: 1.快速清空文件 cat demo.txt < /dev/null 注:linux中有一个经典名言[一切皆文件],/dev/null可以认为是一个特殊的空文件,更形象 ...