目前我正在开展CRM项目。在这个项目中,我必须将数据发送到Web服务。此操作必须适用于自定义工作流程。为了进行Web服务调用我需要身份验证令牌,目前我正在尝试从CodeActivityContext获取ITokenService,它正在检索null,有关如何在工作流环境中获取ITokenService的任何建议吗?
>
protected override void Execute(CodeActivityContext executionContext)
{
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
ITokenService TokenService = (ITokenService)executionContext.GetExtension<ITokenService>();
if(TokenService == null) throw new InvalidOperationException("Token service is null");
serviceFactory.CreateOrganizationService(context.UserId)
try
{
//do something
}
catch
{
//do something
}
}