Skip to main content

Hi,

 

I waould like to implement the K2 WCF service via .NET code. Could you please let me know with basic exmaples of retriving worklist,take action on worklist.

I have gone though developer reference but found that method implemented for that is not working for version which i am using.

So  could you please help me. I am using 4.6.6 version.

 

I am getting below error. Please let me know if you know how to reslove this issue.

 

Error 1 Cannot implicitly convert type 'WCFServiceTest.WorkflowRuntimeWCFService.WorklistItemt]' to 'SourceCode.Workflow.Client.WorklistItemt]' 

Hi Niks,

 

From your error, you are trying to return the WorklistItem type from WCF to the SourceCode.Workflow.Client's WorklistItem type, which are different. You need to use the WorklistItem type from the wcf object.

 

I'm not good with WCF, but here is an code example which configures pretty much everything in the code level.

 

 

Good luck.

JK.

 

 

// K2WCF is my service reference

public void OpenWorkListWCF()
{
Console.WriteLine("Executing OpenWorkListWCF");

BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
EndpointAddress endpoint = new EndpointAddress("http://k2.denallix.com/k2services/WCF.svc/Worklist");

K2WCF.WorklistNavigationServiceClient svc = new K2WCF.WorklistNavigationServiceClient(basicHttpBinding, endpoint);
svc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
//svc.ChannelFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(strLogin, strPassword, strDomain);

try
{
svc.Open();

/* actDataField = Activity level data field
* actXmlField = Activity level xml field
* piDataField = Process Instance level data field
* piXmlField = Process Instance level xml field
*/
K2WCF.WorklistItems] worklist = svc.OpenWorklist(false, false, false, false);
foreach (K2WCF.WorklistItem item in worklist)
{
Console.WriteLine("{0}, {1}, {2}", item.SerialNumber, item.ProcessInstance.Folio, item.Status.ToString());
}
}
catch (Exception ex)
{
svc.Abort();
throw ex;
}
finally
{
if (svc != null)
svc.Close();
}
}

 


Hi Jk,

 

Thanks for you reply. i will check and let you know.


Reply