You can use a Windows Communication Foundation (WCF) client to hit the Nintex Workflow SOAP endpoints. With Visual Studio, you can add the Nintex service as a resource and then build a client. In this post, I show you how to add the resource, create your client, configure your bindings, and then use the export and publish endpoints to retrieve a workflow file and add one to an existing SharePoint list.
In this post we will walk through building a client from scratch. Visual Studio will help with the behind the scenes code to build the proxy and client. You can also download the complete project from the Nintex Platform SDK.
This is what might be called a beta topic. I'm looking for feedback on how to make this subject clearer and more useful to you. Please feel free to send me your feedback or include your feedback as comments to this post. Thanks, Matt
Table of Contents
The following lists covers the major steps for creating a SOAP client, bounding to the endpoints, and then interacting with the Nintex Workflow resources. After the list, you can find more detailed explanations of each of the steps.
To export and publish a Workflow
You can use Visual Studio to create your application.
To create the console application
In the solution, you will add a service reference and point to the Nintex Workflow web services endpoint that contains a list of the available resources. Visual Studio will add the proxy code, and you will create a SOAP client using the Nintex NintexWorkflowWSSoapClient class.You can find more information about using Windows Communication Foundation Services with Visual Studio at MSDN. In addition, you will need to update the bindings which are configured in the app.config file. Here is an image of a solution file for working with the service:
You can use Visual Studio to add the reference to the Nintex Workflow services. Visual Studio will add the code that will enable you to instantiate the SOAP client. The following image shows the Add Service Reference window that opens when you add the service to your project. You can find the service at: http://yourserver/_vti_bin/NintexWorkflow/Workflow.asmx.
To add the service reference
You will need to add the service dependency to your class. The following image shows the Object Browser. You can find the reference under the name of your project.
To add the service dependency
Update the configuration file (app.config) to set your binding settings. The binding contains parameters specified as attributes of the binding element. In addition in the security group, you will need to specify the mode as TransportCredentialOnly. When you instantiate the SOAP client, you will specify the name of the binding. For instance in this example, NintexWorkflowWSSoapClient soapClient = new NintexWorkflowWSSoapClient("NintexWorkflowWSSoap")
specifies the NintexWorkflowWSSoap binding indicated by the attribute name in the binding element.
To update app.config
<binding name="NintexWorkflowWSSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
maxReceivedMessageSize="100000000" messageEncoding="Text" textEncoding="utf-8"
<readerQuotas maxDepth="32" maxStringContentLength="999999999" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
Add the variables you will use to work with the endpoint to the class. Identify the pieces of information you need to interact with the endpoint. In the code sample, you are publishing to the workflow named workflowpublishformsource.
var workflowName = "PublishFormXMLtoTarget"; //
var sourceListName = "workflowpublishformsource"; //
var workflowfile = "";
var targetlistname = "RecieveWorkflow";
var fullFilePath = @"C:\out\exportworkflow.nwf";
With the service references, you can access the NintexWorkflowWSSoapClient. Instiate the SOAP client, and then add your user name, password, domain. In addition you can specify NTLM and allow for impersonation.
soapClient.ClientCredentials.Windows.ClientCredential.UserName = "username";
soapClient.ClientCredentials.Windows.ClientCredential.Password = "password";
soapClient.ClientCredentials.Windows.ClientCredential.Domain = "domain";
soapClient.ClientCredentials.Windows.AllowNtlm = true;
soapClient.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
To use the service over an HTTPS connection, you will need to change the endpoint to an HttpsTransportBindingElement.
You can specify the specific endpoint using the SOAP client object. In this example, you are retrieving the workflow and assigning to the workflow file string variable.
For more information on the available Nintex Workflow endpoints you can check out the SDK. See Service operations.
var retrieved = getWorkflow(soapClient, workflowName, sourceListName, workflowfile, fullFilePath);
var copied = CopyListWorkflow(soapClient, workflowName, sourceListName, targetlistname);
This method uses the ExportWorkflow endpoint. You can see the code sample below for an example of how you can use the endpoint. Refer to the API documentation for more information about the endpoint.
public static bool getWorkflow(NintexWorkflowWSSoapClient soapClient, string workflowName, string sourceListName,
string workflowfile, string fullFilePath)
workflowfile = soapClient.ExportWorkflow(
File.WriteAllText(fullFilePath, workflowfile, Encoding.Unicode);
catch (Exception ex)
This method export a workflow file using the ExportWorkflow endpoint. And then the method changes the name to name and the string "_Copy2." The method then posts the file to a new workflow file using the PublishFormNWXML. For more informaiton about this endpoint, see the API documentation.
public static bool CopyListWorkflow(NintexWorkflowWSSoapClient soapClient, string workflowName,
string sourceListName, string targetListName)
// Export the workflow from the source list to a StringBuilder object, and then
// import the workflow from the StringBuilder object to the target list.
// First, export the workflow to a StringBuilder object.
var sb = new StringBuilder(
Console.Write("\nCopyListWorkflow: export success\n");
// Now, import the workflow from the StringBuilder object. The PublishFromNWFXml
// service operation is configured so that it does not save the workflow
// if the workflow cannot be published.
if (sb.Length > 0)
workflowName + "_Copy2",
Console.Write("\nCopyListWorkflow: copy success\n");
catch (Exception ex)
And that is it. I hope you can explore some of the other end points in your reference. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.