Dynamics CRM 2011 编程系列(22):用插件调用Web Service
2012-05-30 11:45
387 查看
在实施项目的过程中进程会碰到系统对接的问题,也就是系统接口。Web Service正是解决这类问题而诞生的,SOA的最终目标就是灵活的整合企业中的各类系统,降低系统与系统的集成成本。
基于系统的集成要求,通过插件调用Web Service也是件和正常的事情。接下来我们看个简单的例子吧:
图1 部署Web Service
图2 在插件中引用Web Service
图3
图4
图5
图6
图7
图8
图10
本博文引用的Web Service不支持.NET 4.0架构。
基于系统的集成要求,通过插件调用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 编程系列(23):用插件调用WCF
- Dynamics CRM 2011 编程系列(25):插件的依赖注入
- Dynamics CRM 2011 编程系列(20):插件队列
- Dynamics CRM 2011 编程系列(21):插件调试
- Dynamics CRM 2011 编程系列(16):插件
- Dynamics CRM 2011 编程系列(24):在插件中使用早期绑定
- Dynamics CRM 2011 编程系列(18):插件中的Read操作
- Dynamics CRM 2011 编程系列(17):用插件来实现实体的CRUD
- Dynamics CRM 2011 编程系列(19):插件中的事务
- Dynamics CRM 2011 编程系列(3):JS脚本编程之onsave事件
- Dynamics CRM 2011 编程系列(31):Ribbon的开发一(添加按钮,选项卡,Jewel)
- Dynamics CRM 2011 编程系列(13):JS编程之Who Am I
- Dynamics CRM 2011 编程系列 (6):JS脚本编程之实体的CRUD[Create,Read]
- Dynamics CRM 2011 编程系列(9):JS编程之客户端实体
- Dynamics CRM 2011 编程系列(2):JS脚本编程之onload事件
- Dynamics CRM 2011 编程系列(28):使用SQL Server Profiler找表
- Dynamics CRM 2011 编程系列:自定义工作流
- Dynamics CRM 2011 编程系列(3):JS脚本编程之onsave事件
- Dynamics CRM 2011 编程系列(4):JS脚本编程之onchange事件
- Dynamics CRM 2011 编程系列(27):使用触发器