How to Approve or Reject a Nintex Task using Nintex Web Service API ProcessTaskResponse2 method
This was really challenging however at the end we were able to achieve this. I would like to mention my manager Mr. Yamen Hmidan for his extra ordinary thinking level that helped me to get this done.
My web.config goes here.
Now call the service and pass the parameters mentioned in the Get method and Nintex web service will approve the task.
Cheers.
Problem Statement:
We want to approve or reject Nintex Tasks using its web service API and using its ProcessTaskResponse2 method in C# by creating another web service. The C# web API will call the Nintex web API and approve or reject the task.
Solution:
I have created a new Web Service API Project in Visual Studio 2019 and added the Nintex service reference in my project. All the operations provided by Nintex are now available in my project under Connected Services. I called the reference as NintexServiceReference in my code.
Here is my C# code of Approve class.
Note: This code might not work 100% for you as this is just a direct copy paste and have dependencies on my other classes. This is just to give you the idea of my Get method.
using System;
using System.Net;
using System.Web.Http;
using SharePoint10.NintexServiceReference;
using System.ServiceModel;
using CommonLayer.Settings;
namespace SharePoint10.Controllers
{
public class NintexApproveRejectController :
ApiController
{
public string Get( string comments, string decision, int taskID)
{
ServicePointManager.ServerCertificateValidationCallback +=
(mender, certificate, chain,
sslPolicyErrors) => true;
BasicHttpBinding binding = new BasicHttpBinding();
binding.OpenTimeout = new TimeSpan(2, 0, 0);
binding.CloseTimeout = new TimeSpan(2, 0, 0);
binding.SendTimeout = new TimeSpan(2, 0, 0);
binding.ReceiveTimeout = new TimeSpan(2, 0, 0);
//For Https web
applications
binding.Security.Mode =
BasicHttpSecurityMode.Transport;
//For Http web
applications
//binding.Security.Mode
= BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Ntlm;
EndpointAddress endpoint =
NintexWorkflowWSSoapClient NWSC = new NintexWorkflowWSSoapClient(binding,
endpoint);
NWSC.ClientCredentials.Windows.ClientCredential = new
System.Net.NetworkCredential(Test_SystemAccountCredentials.UserName,
Test_SystemAccountCredentials.Password, Test_SystemAccountCredentials.Domain);
ProcessTaskResponseResult res =
NWSC.ProcessFlexiTaskResponse2(comments, decision, taskID, "Workflow Tasks");
return res.ToString();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your
ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<authentication mode="Windows" />
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default
/nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default
/nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NintexWorkflowWSSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="200524288" maxReceivedMessageSize="200524288" useDefaultWebProxy="true">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="NintexWorkflowWSSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://mysite.com/department/_vti_bin/NintexWorkflow/workflow.asmx" binding="basicHttpBinding" bindingConfiguration="NintexWorkflowWSSoap" contract="NintexServiceReference.NintexWorkflowWSSoap" name="NintexWorkflowWSSoap" />
</client>
</system.serviceModel>
</configuration>
Comments
Post a Comment