wcf

Newtonsoft 六个超简单又实用的特性,值得一试 【下篇】

谁说我不能喝 提交于 2020-08-14 11:04:15
一:讲故事 上一篇介绍的 6 个特性从园子里的反馈来看效果不错,那这一篇就再带来 6 个特性同大家一起欣赏。 二:特性分析 1. 像弱类型语言一样解析 json 大家都知道弱类型的语言有很多,如: nodejs,python,php,它们有一个🐮👃的地方就是处理json,不需要像 强类型语言 那样还要给它配一个类,什么意思呢? 就拿下面的 json 说事。 { "DisplayName": "新一代算法模型", "CustomerType": 1, "Report": { "TotalCustomerCount": 1000, "TotalTradeCount": 50 }, "CustomerIDHash": [1,2,3,4,5] } 这个 json 如果想灌到 C# 中处理,你就得给它定义一个适配的类,就如 初篇 的客户算法模型类,所以这里就有了一个需求,能不能不定义类也可以自由解析上面这串 json 呢??? 哈哈,当然是可以的, 反序列化成 Dictionary 即可,就拿提取 Report.TotalCustomerCount 和 CustomerIDHash 这两个字段演示一下。 static void Main(string[] args) { var json = @"{ 'DisplayName': '新一代算法模型', 'CustomerType': 1,

Newtonsoft 六个超简单又实用的特性,值得一试 【下篇】

血红的双手。 提交于 2020-08-14 04:19:25
一:讲故事 上一篇介绍的 6 个特性从园子里的反馈来看效果不错,那这一篇就再带来 6 个特性同大家一起欣赏。 二:特性分析 1. 像弱类型语言一样解析 json 大家都知道弱类型的语言有很多,如: nodejs,python,php,它们有一个????????的地方就是处理json,不需要像 强类型语言 那样还要给它配一个类,什么意思呢?就拿下面的 json 说事。 { "DisplayName": "新一代算法模型", "CustomerType": 1, "Report": { "TotalCustomerCount": 1000, "TotalTradeCount": 50 }, "CustomerIDHash": [1,2,3,4,5] } 这个 json 如果想灌到 C# 中处理,你就得给它定义一个适配的类,就如 初篇 的客户算法模型类,所以这里就有了一个需求,能不能不定义类也可以自由解析上面这串 json 呢???哈哈,当然是可以的, 反序列化成 Dictionary 即可,就拿提取 Report.TotalCustomerCount 和 CustomerIDHash 这两个字段演示一下。 static void Main(string[] args) { var json = @"{ 'DisplayName': '新一代算法模型', 'CustomerType':

WCF设计服务协议(一)

北战南征 提交于 2020-08-13 19:50:23
实现WCF的步骤如下: 设计服务协议 实现服务协议 配置服务 托管服务 生成客户端(这步可有可无) 设计或定义服务协议要么使用接口,要么使用类。建议接口,使用接口好处一堆例如修改接口的实现,但是服务协定有无需改变。 设计服务协议,接口上使用 ServiceContractAttribute ,方法上使用OperationContractAttribute。 服务协议的每个方法的参数和返回值的类型都必须是可序列化的,默认.net自带的类型都是可序列化的。 如果有在接口里面使用到自定义的类型,就要使用到数据协议了,那自定义的类型 使用DataContractAttribute,里面属性成员使用DataMemberAttribute。 namespace DataContractinWCF.Web { [ServiceContract] public interface IService1 { [OperationContract] List <Customer> GetCustomerData( int CustomerID); } [DataContract] public class Customer { private string m_Name; private int m_Age; private int m_Salary; private string m

《微软应用架构指南 (第2版)》

自闭症网瘾萝莉.ら 提交于 2020-08-12 23:12:50
**《微软应用架构指南 (第2版)》 ========== ========== ========== [作者] (美) Patterns & Practices [译者] (中) 朱晔 高翔 王敏 [出版] 电子工业出版社 [版次] 2010年11月 第1版 [印次] 2010年11月 第1次 印刷 [定价] 69.00元 ========== ========== ========== 【前言】 (P001) 开发人员和方案解决架构师通常是游走在“黄金方案”和“即时方案”之间。 架构就是利用现有的技术和工具来创造尽可能多的商业价值,一方面关注现有业务所提出的需求和限制,另一方面着眼于未来通过可伸缩性、灵活性以及可维护性等方面最大化价值。 【第01章】 【什么是软件架构】 (P003) 软件应用架构是一个结构化解决方案,这种结构化解决方案一方面可以满足所有技术和运营需求,另一方面可以满足常见的质量特性 (quality attribute) 要求,例如性能、安全以及可管理性等。它涵盖了受多重因素影响的一系列决策,每种决策对质量、性能、可维护性及应用程序总体的成功都有相当大的影响。 (P004) 一个失败的架构带来的风险包括软件不稳定、不能支持既有或将来的业务需求、或难以在生产环境中部署和管理。 系统在设计的时候需要考虑用户、系统 (IT基础结构) 和业务。对于每一个方面

配置WCF同时支持WSDL和REST,swaggerwcf生成文档

混江龙づ霸主 提交于 2020-08-12 14:38:43
配置WCF同时支持WSDL和REST,SwaggerWCF生成文档 VS创建一个WCF工程,通过NuGet添加SwaggerWcf 创建完成后通过 程序包管理控制台 pm> Install-Package SwaggerWcf 也可在 工具 -> NuGet包管理器 -> 管理解决方案的NuGet程序包 安装。 配置 首先对项目添加Global.asax文件,改动如下: protected void Application_Start( object sender, EventArgs e) { RouteTable.Routes.Add( new ServiceRoute( " Service1 " , new WebServiceHostFactory(), typeof (Service1))); RouteTable.Routes.Add( new ServiceRoute( " api-docs " , new WebServiceHostFactory(), typeof (SwaggerWcfEndpoint))); } Web.config配置文件改动如下: 在<configuration>节点 下 添加 < configSections > < section name ="swaggerwcf" type ="SwaggerWcf.Configuration

Newtonsoft 六个超简单又实用的特性,值得一试 【下篇】

梦想的初衷 提交于 2020-08-11 06:25:30
一:讲故事 上一篇介绍的 6 个特性从园子里的反馈来看效果不错,那这一篇就再带来 6 个特性同大家一起欣赏。 二:特性分析 1. 像弱类型语言一样解析 json 大家都知道弱类型的语言有很多,如: nodejs,python,php,它们有一个🐮👃的地方就是处理json,不需要像 强类型语言 那样还要给它配一个类,什么意思呢? 就拿下面的 json 说事。 { "DisplayName": "新一代算法模型", "CustomerType": 1, "Report": { "TotalCustomerCount": 1000, "TotalTradeCount": 50 }, "CustomerIDHash": [1,2,3,4,5] } 这个 json 如果想灌到 C# 中处理,你就得给它定义一个适配的类,就如 初篇 的客户算法模型类,所以这里就有了一个需求,能不能不定义类也可以自由解析上面这串 json 呢??? 哈哈,当然是可以的, 反序列化成 Dictionary 即可,就拿提取 Report.TotalCustomerCount 和 CustomerIDHash 这两个字段演示一下。 static void Main(string[] args) { var json = @"{ 'DisplayName': '新一代算法模型', 'CustomerType': 1,

WCF Self-Host to access from internet

ⅰ亾dé卋堺 提交于 2020-08-10 20:12:48
问题 I am trying to create a service to consume it through the internet, but for some reason I cannot access it and I need help finding the error I am making. I leave the code for you to see. public class ServiceHost<T> : System.ServiceModel.ServiceHost { public ServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { } public ServiceHost(object singletonInstance, params Uri[] baseAddresses) :base(singletonInstance, baseAddresses) { } protected ServiceHost() :

WCF transport security: socket connection was aborted

会有一股神秘感。 提交于 2020-08-10 17:42:09
问题 I have a problem in getting transport security to work. I have 2 services (A & B) running in the same server. service A will call service B to perform some task. Without any security, I can communicate just fine. But when I turn on transport security with the following settings: security mode = transport TransportClientCredentialType = Windows ProtectionLevel = EncryptAndSign I got error when service A calls service B: System.ServiceModel.CommunicationException: The socket connection was

WCF transport security: socket connection was aborted

Deadly 提交于 2020-08-10 17:41:13
问题 I have a problem in getting transport security to work. I have 2 services (A & B) running in the same server. service A will call service B to perform some task. Without any security, I can communicate just fine. But when I turn on transport security with the following settings: security mode = transport TransportClientCredentialType = Windows ProtectionLevel = EncryptAndSign I got error when service A calls service B: System.ServiceModel.CommunicationException: The socket connection was

Encoding issue when passing URL Parameters with BizTalk WCF-WebHttp Send Port

佐手、 提交于 2020-08-09 17:51:52
问题 I'm trying to call an RESTful API within BizTalk. I need to make a GET against the following endpoint: https://mycompany.com/buyer/sandboxevol/ I have below mappings configured in my Send Port <BtsHttpUrlMapping> <Operation Name='Operation_1' Method='GET' Url='/page.aspx/en/eai/api/supplier/{id}?apikey={apikey}&format={format}' /> </BtsHttpUrlMapping> paramater apikey has value as XXXXXXXXXXzvrpZHbMdKY75zbszhGOu%2bfnmP7Ms%3d. I have checked this and verified from suspended instance. But error