Accessing the View Flow URL with the WCF service

The View Flow URL can be accessed through the WCF service

URI

[WORKSPACE BASE URL]/K2Services/WCF.svc

Setup

Follow the steps below to set up an example for accessing the View Flow URL:

  1. Open the URL :
  2. The following page will open
  3. Copy the URL and Open K2 Designer for Visual Studio
  4. Create a new C# Console Application
  5. In the Solution Explorer right click on the References Node and select Add Service Reference:
  6. In the Address paste the URL and click on Go
  7. Change the Namespace to WCF and click OK :
  8. Type the following code in the Static void Main(string[] args) method

    WCF.ProcessNavigationServiceClient client = new WCF.ProcessNavigationServiceClient();
    WCF.ProcessInstance pi = client.OpenProcessInstance("1", true, true); //change the "1" to your process instance
    Console.WriteLine(pi.ViewFlow);
    Console.Read();

    Change the “1” to your process instance ID number

  9. Run the console application
  10. The View Flow URL is returned

Troubleshooting

If you receive the following error, you will have to update the web.config

Follow the steps below to update the web.config

  1. Open the web.config in the following location : C:\Program Files (x86)\K2 blackpearl\WebServices\K2Services
  2. Search for the following XML:

    <basicHttpBinding>
            <!-- HTTP binding for WCF.svc endpoints -->
            <!-- Ensure the WCF.svc endpoints are enabled when enabling these bindings -->
            <binding name="SourceCode.Services.WcfBinding+HTTP">
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="None" />
              </security>
            </binding>
            <!-- HTTPS binding for WCF.svc endpoints -->
            <!-- Ensure the WCF.svc endpoints are enabled and SSL in IIS is configured when enabling these bindings
         <binding name="SourceCode.Services.WcfBinding+HTTPS">
          <security mode="Transport">
           <transport clientCredentialType="Windows" />
          </security>
         </binding>
         -->
            <!-- HTTP binding for SyncWCF.svc endpoints -->
            <!-- WARNING: Basic over HTTP is inherently insecure -->
            <!-- Ensure the SyncWCF.svc endpoints are enabled when enabling this binding
         <binding name="SourceCode.Services.SyncWcfBinding+HTTP">
          <security mode="TransportCredentialOnly">
           <transport clientCredentialType="None" />
          </security>
         </binding>

  3. Change the highlighted “None” to “Windows”

    <basicHttpBinding>
            <!-- HTTP binding for WCF.svc endpoints -->
            <!-- Ensure the WCF.svc endpoints are enabled when enabling these bindings -->
            <binding name="SourceCode.Services.WcfBinding+HTTP">
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Windows" />
              </security>
            </binding>
            <!-- HTTPS binding for WCF.svc endpoints -->
            <!-- Ensure the WCF.svc endpoints are enabled and SSL in IIS is configured when enabling these bindings
         <binding name="SourceCode.Services.WcfBinding+HTTPS">
          <security mode="Transport">
           <transport clientCredentialType="Windows" />
          </security>
         </binding>
         -->
            <!-- HTTP binding for SyncWCF.svc endpoints -->
            <!-- WARNING: Basic over HTTP is inherently insecure -->
            <!-- Ensure the SyncWCF.svc endpoints are enabled when enabling this binding
         <binding name="SourceCode.Services.SyncWcfBinding+HTTP">
          <security mode="TransportCredentialOnly">
           <transport clientCredentialType="None" />
          </security>
         </binding>

  4. Save the file, re-open your console application, right click on your service reference and click on Update Service Reference:
  5. Run the console application again
See Also