我将尝试从SharePoint外部启动Nintex Workflow 2010。我似乎无法找到任何关于如何从控制台应用程序调用它的示例。是否有人拥有代码示例或知道实际显示此内容的博客。
谢谢, 神保
答案 0 :(得分:0)
SharePoint 2010不支持CSOM Workflows API,但您可以为此目的使用SharePoint Workflow Web Services (SOAP)。
使用Workflow.StartWorkflow Method为客户启动项目的工作流程。
workflow.asmx
服务的URL示例:<web url>/_vti_bin/workflow.asmx
并指定命名空间名称,例如WorkflowSvc
为了使Sharepoint Web Services能够使用NTLM身份验证,请进行以下更改app.config
文件。
将security
部分替换为:
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
为:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
以下代码示例演示了如何在项目上启动工作流程:
var workflowClient = new WorkflowSvc.WorkflowSoapClient();
workflowClient.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
workflowClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var workflowParameters = "<my:myFields " +
"xml:lang=\"en-us\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\">" +
"</my:myFields>";
var listItemUrl = "http://contoso.intranet.com/Documents/Order.docx";
var wfTemplateId = new Guid("{0fd3e822-a3b1-45c1-990c-20cb9731e74f}");
var result = workflowClient.StartWorkflow(listItemUrl, wfTemplateId, XElement.Parse(workflowParameters));