Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've installed Nintex Workflows 2013. But when I'm trying to publish a workflow through the Nintex Webservice, it fails. What I've done:

1) Got my file as a string
2) Changed values in workflow
3) Convert to byte array
4) Connect to Nintex Workflow Service -> My problem...
5) Publish workflow to web

The code (for point nr 4): I've added a service reference to the webservice (=NintexWorkflowWS) But I need to set the URL and credentials (since this will be deployed on test/production)

private void ActivateWorkflow(byte[] doc, string teamRoomUrl)
{
    NintexWorkflowWS.NintexWorkflowWS webService = new NintexWorkflowWS.NintexWorkflowWS();
    webService.Url = teamRoomUrl.TrimEnd('/') + "/_vti_bin/nintexworkflow/workflow.asmx";
    webService.UseDefaultCredentials = true;
    webService.PublishFromNWF(doc, "Documents", "Move Documents", true);
}

On the last line it throws an error:

{System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
  at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
  at ...

This always fails... Does anyone knows how to do this???

share|improve this question

closed as off-topic by Robert Lindgren, RJ Cuthbertson, PirateEric, Benny MCSA Office365, Jesus Shelby Jul 24 '13 at 2:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
The Nintex forums are better suited for this type of question, which is why it attracted the close votes. –  Jesus Shelby Jul 24 '13 at 2:08

1 Answer 1

up vote 0 down vote accepted

I've found the answer... just had to run this in elevated permissions:

private void ActivateWorkflow(byte[] doc, string teamRoomUrl)
{
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        try
        {
            NintexWorkflowWS.NintexWorkflowWS webService = new NintexWorkflowWS.NintexWorkflowWS();
            webService.Url = teamRoomUrl.TrimEnd('/') + "/_vti_bin/nintexworkflow/workflow.asmx";
            webService.UseDefaultCredentials = true;
            webService.PublishFromNWF(doc, "Documents", "Move Documents", true);
        }
        catch (Exception ex)
        {
            //log
        }
    });
}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.