通过crm工作流程调用Web服务

时间:2016-04-06 14:01:54

标签: web plugins service workflow crm

目前我正在研究一个crm项目。在这个项目中,我必须将数据发送到Web服务并获取精确的数据。这个操作必须在自定义工作流程上工作,但我陷入困境,我不知道该怎么做?有什么建议吗?

Here is my service code; 


var tmpIncident = getIncidentById(organizationServiceContext);
        if (tmpIncident != null) //if we have decent incident we connect service and proceed the data.
        {
            GetCustomerInfoService.TransactionServiceClient client = new GetCustomerInfoService.TransactionServiceClient();
            GetCustomerInfoService.TransactionRequest request = new GetCustomerInfoService.TransactionRequest();


            #region authentication  
            request.AuthenticationData.UserName = "user";
            request.AuthenticationData.Password = "pass";
            #endregion

            Guid id = Guid.NewGuid(); //create random guid
            request.RequestId = id.ToString();
            request.OrderNumber = tmpIncident.vrp_ordernumber;

            GetCustomerInfoService.TransactionResponse response = client.GetTransactionByOrderNumber(request);
            tmpIncident.CustomerId = new EntityReference("Contact", new Guid(response.Message));


            this.updateChanges(organizationServiceContext, tmpIncident);

            client.Close();
        } 

当我测试插件时,我收到了该错误;

  

错误讯息:

未处理的异常:System.InvalidOperationException:无法在ServiceModel客户端配置部分中找到引用合同“GetCustomerInfoService.ITransactionService”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。    在System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint,String configurationName)    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName,EndpointAddress address)    在System.ServiceModel.ChannelFactory 1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.ConfigurationEndpointTrait 1.CreateSimplexFactory()    在System.ServiceModel.ClientBase 1.CreateChannelFactoryRef(EndpointTrait 1 endpointTrait)    在System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()    在Vrp.Crm.PluginLibrary2013.GetCustomerInfoService.TransactionServiceClient..ctor()in:第0行    在Vrp.Crm.PluginLibrary2013.CustomWorkflows.SetCumstomerIdToIncident.Execute(CodeActivityContext context)c:\ Veripark \ Projects \ gisik \ DRCRM.VERITOUCH.CRM2013 \ PluginLibrary2013 \ CustomWorkflows \ CheckSubIncidentForMainIncident.cs:第72行    在System.Activities.CodeActivity.InternalExecute(ActivityInstance实例,ActivityExecutor执行器,BookmarkManager bookmarkManager)    at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,BookmarkManager bookmarkManager,Location resultLocation)

1 个答案:

答案 0 :(得分:0)

假设您正在使用Dynamics CRM。这是一个高级概述:

  1. 创建一个自定义工作流活动,以实际调用Web服务。这应该可以帮助您入门:https://msdn.microsoft.com/en-us/library/gg328515.aspx
  2. 自定义活动的输出参数会将结果从网络服务返回到调用的CRM工作流程。
  3. 最后创建将使用您的自定义活动的工作流及其触发器。更多信息: http://crmbook.powerobjects.com/system-administration/processes/workflows/ https://msdn.microsoft.com/en-us/library/gg328264.aspx
  4. 我希望这足以让你走上正确的道路。