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以上的应用都用到了这个控件,所以就给大家介绍一下,前面的文章中也 ...
随机推荐
- 如何读懂复杂的C语言声明
本文已迁移至: http://www.danfengcao.info/c/c++/2014/02/25/howto-understand-complicated-declaration-of-c.ht ...
- Solr部分更新MultiValued的Date日期字段时报错及解决方案
问题描述如标题. 异常信息如下: Result Caused by: org.apache.solr.common.SolrException: Invalid Date String:'Mon Se ...
- Fedora 23安装配置mysql数据库,修改初始密码及登陆
下载MySQL5.7.9 yum仓库 wget http://dev.mysql.com/get/mysql57-community-release-fc23-7-noarch.rpm rpm -iv ...
- Python基础之面向对象
一.面向对象概述 面向对象编程——Object Oriented Programming,简称OOP,是一种程序设计思想.OOP把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数. 面向过程 ...
- iOS实现用控制器作为弹框效果(modalPresentationStyle)
如图: 中间模块其实为一个正常vc控制器,一般我们present,都是采用默认style 但如果要实现这种,写法如下: navigationC.modalPresentationStyle = UIM ...
- android radiogroup样式(设置切换背景与文字颜色)
main.xml <RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_cont ...
- Eclipse下还原删除的文件
做项目的时候,不小心把Eclipse下的么个文件删除了,虽然有svn但是最新修改的代码没有提交,怎么办,在网上查了下,eclipse是可以还原删除文件的.具体做法如下所示 恢复删除的文件 1 在项目上 ...
- [bootsrap]模态框使用例
<a href="#modal1" role="button" class="btn btn-primary btn-sm" data ...
- GLine游戏(Win32GUI实现,CodeBlocks+GCC编译)
游戏规则: 在10X10的棋盘上有五种颜色的棋子. 点击一个棋子,再点击一个空格子,如果两者之间有一条路径的话,棋子会移动到空格子内. 每移动一次,棋盘上会增加三个棋子,其位置和颜色都是随机的. 当横 ...
- LCA 倍增||树链剖分
方法1:倍增 1498ms #include <iostream> #include <cstdio> #include <algorithm> #include ...