Dynamics CRM 2011 编程系列(22):用插件调用Web Service
来源:互联网 发布:png软件图标 编辑:程序博客网 时间:2024/06/08 02:52
在实施项目的过程中进程会碰到系统对接的问题,也就是系统接口。Web Service正是解决这类问题而诞生的,SOA的最终目标就是灵活的整合企业中的各类系统,降低系统与系统的集成成本。
基于系统的集成要求,通过插件调用Web Service也是件和正常的事情。接下来我们看个简单的例子吧:
图1 部署Web Service
图2 在插件中引用Web Service
图3
图4
图5
图6
图7
图8
图10
插件代码
using System;using System.Collections.Generic;using System.Text;using Microsoft.Xrm.Sdk;using Microsoft.Xrm.Sdk.Messages;namespace Plugin21{ public class CallWS:IPlugin { public void Execute(IServiceProvider serviceProvider) { IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); Entity curEntity = context.InputParameters["Target"] as Entity; int num1=(int)curEntity["new_num1"]; int num2=(int)curEntity["new_num2"]; int result = 0; OptionSetValue optType = (OptionSetValue)curEntity["new_opt_type"]; Service.Service calculator = new Service.Service(); switch (optType.Value) { case 100000000: result = calculator.AND(num1, num2); break; case 100000001: result = calculator.Subtractions(num1, num2); break; case 100000002: result = calculator.Multiplie(num1, num2); break; case 100000003: result = calculator.Division(num1, num2); break; } if (curEntity.Attributes.Contains("new_result")) { curEntity["new_result"] = result; } else { curEntity.Attributes.Add("new_result", result); } } }}
注意事项
本博文引用的Web Service不支持.NET 4.0架构。
- Dynamics CRM 2011 编程系列(22):用插件调用Web Service
- Dynamics CRM 2011 编程系列(23):用插件调用WCF
- Dynamics CRM 2011 编程系列(16):插件
- Dynamics CRM 2011编程系列(48): WCF Service 和 Web Service 程序的部署
- Dynamics CRM 2011编程系列
- Dynamics CRM 2011编程系列
- Dynamics CRM 2011 编程系列(18):插件中的Read操作
- Dynamics CRM 2011 编程系列(19):插件中的事务
- Dynamics CRM 2011 编程系列(20):插件队列
- Dynamics CRM 2011 编程系列(21):插件调试
- Dynamics CRM 2011 编程系列(25):插件的依赖注入
- Dynamics CRM 2011 编程系列(17):用插件来实现实体的CRUD
- Dynamics CRM 2011 编程系列:自定义工作流
- Dynamics CRM 2011 编程系列(24):在插件中使用早期绑定
- Dynamics CRM 2011编程系列(37):调用报表的72般绝技
- Dynamics CRM 2011编程系列(38):调用报表的神器(GhostHook)
- Dynamics CRM 2011编程系列(55):Dynamics CRM 集成开发简述
- Dynamics CRM 2011 编程系列(26):自定义工作流
- 使用lua虚拟机的一个注意事项
- Dynamics CRM 2011 编程系列(25):插件的依赖注入
- 每日一练
- php安装程序的版本选择
- 《Effective C++》条款03:两个成员函数如果只是常量性不同可以被重载
- Dynamics CRM 2011 编程系列(22):用插件调用Web Service
- TTS Events Explanation
- Dynamics CRM 2011 编程系列(23):用插件调用WCF
- Short URL implement
- 日期格式参考extjs api文档中的Date类型
- Android界面基本属性
- windows开机出现‘应用程序正常初始化(0xc0000044)失败’进不了系统
- 各国插座标准
- The listenersupports no services