AnsweredAssumed Answered

Terminate Workflow by Code

Question asked by shoeb on Oct 28, 2015
Latest reply on Nov 3, 2015 by waltont

The following Code was made for terminating the REQUEST
which works fine on the Development Server and error on Production Server

 

   
var

wcfWindowUserName = ConfigurationManager.AppSettings["WCFWindowUserName"];

          
var wcfWindowPassword = ConfigurationManager.AppSettings["WCFWindowPassword"];

          
var wcfDomain = ConfigurationManager.AppSettings["WCFDomain"];

         

            try

          
{

 

 

              
var webServiceUrl = web.Url;

              
//construct web service url

              
if (!webServiceUrl.EndsWith("/"))

                  
webServiceUrl += "/";

              
webServiceUrl += "_vti_bin/nintexworkflow/workflow.asmx";

          

                //Call the Nintex web service to publish/save the workflow

              
var service = new
WorkflowWS.NintexWorkflowWS

              
{

                  
Timeout = 999999999,

                  
Url = webServiceUrl,

                  
// Credentials = new NetworkCredential(wcfWindowUserName,
wcfWindowPassword, wcfDomain)

   
              

                };

 

              
var lst = web.Lists[listName];

              
var lstId = lst.ID;

              
//var itemGUID = new
Guid(Request.QueryString["rfID"]);

              
var itemId = GetItemIDByTitle(lst,
itemGUID.ToString());

              
var wfInstanceId =
GetWorkflowInstanceIdWithUpdateStatus(itemGUID, type);

 

              
if (itemId != 0)

              
{

                  
service.Credentials = new NetworkCredential(wcfWindowUserName,
wcfWindowPassword, wcfDomain);

                  
service.UnsafeAuthenticatedConnectionSharing = true;

                  
service.PreAuthenticate = true;

                  
//service.Credentials = CredentialCache.DefaultCredentials;

                  
service.TerminateWorkflow(lstId, itemId, wfInstanceId);

                  
//DeleteListItem(lst, itemId);

 

              
}

 

This is the Following Message I am receiving

 

The request failed
with HTTP status 401: Unauthorized.System.Web.Services

Outcomes