Connection.OpenProcessInstance: viewflow URL and datafields throw exceptions

  • 13 November 2016
  • 2 replies
  • 2 views

Badge +2

When using the K2 client API and getting a process instance by calling Connection.OpenProcessInstance(int id), i am trying to get the viewflow URL and the datafields.  Both of those properties are throwing exceptions when tryingto access them.  Other properties on the process instance all populate fine (name, folio, startdate, etc.).

 

When I debug the code, sometimes the values populate, sometimes they do not (for the same process instance).

 

I cannot figure out why these properties throw exceptions.

 

Here is the code I am using:

 

using (var connection = new Connection())
{
var connectionStringBuilder = new SCConnectionStringBuilder
{
Authenticate = true,
Integrated = false,
IsPrimaryLogin = true,
EncryptedPassword = false,
Host = k2ConnectionInformation.ServerHostName,
Port = k2ConnectionInformation.WorkflowServerPort,
UserID = k2ConnectionInformation.LoginUserID,
Password = k2ConnectionInformation.LoginUserPassword,
WindowsDomain = k2ConnectionInformation.LoginUserDomain,
SecurityLabelName = k2ConnectionInformation.LoginUserSecurityLabel
};

connection.Open(k2ConnectionInformation.ServerHostName, connectionStringBuilder.ConnectionString);

if (impersonatedUserFqn.HasValue())
{
connection.ImpersonateUser(impersonatedUserFqn);
}

var processInstance = connection.OpenProcessInstance(model.ProcessInstanceID);
}
{
"ClassName": "ClientException",
"Data": null,
"ExceptionMethod": "8
Send
SourceCode.Workflow.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d
SourceCode.Workflow.Client.SocketClient
Void Send(UInt32, SourceCode.Workflow.Client.MessageType, SByte*, Int32)",
"HResult": -2146233088,
"HelpURL": null,
"InnerException": null,
"Message": "Send failed with error: An operation was attempted on something that is not a socket. ",
"RemoteStackIndex": 0,
"RemoteStackTraceString": null,
"Source": "SourceCode.Workflow.Client",
"StackTraceString": "at SourceCode.Workflow.Client.SocketClient.Send(UInt32 sock, MessageType type, SByte* buf, Int32 len)
at SourceCode.Workflow.Client.SocketClient.Send(ClientMessage Msg, Int32 Start, Int32 Length)
at SourceCode.Workflow.Client.InternalConnection.Call(ArchiveX ar, MessageType msgtype)
at SourceCode.Workflow.Client.InternalConnection.CallFunction(ArchiveX ar)
at SourceCode.Workflow.Client.DataField.LoadValue()
at SourceCode.Workflow.Client.DataField.get_MetaData()
at K2.Services.Factories.WorkflowClient.DataFieldModelFactory.Create(DataField dataField)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at K2.Services.Factories.WorkflowClient.DataFieldModelFactory.CreateMany(DataFields dataFields)
at K2.Services.Factories.WorkflowClient.ProcessInstanceModelFactory.Create(ProcessInstance processInstance)
at K2.Services.WorkflowClientService.<>c__DisplayClass10_0.<OpenProcessInstance>b__0()
at K2.Services.WorkflowClientService.RunWithK2ClientExceptionHandling(Func`1 code)",
"WatsonBuckets": null
}

2 replies

Userlevel 5
Badge +18

It could be the HostName or Port that you are using:


 


        Host = k2ConnectionInformation.ServerHostName,
Port = k2ConnectionInformation.WorkflowServerPort,

 Please check that these are correct.   Are you using 5555, 5252, or perhaps some custom port configuration?

Badge +2

I am using the standard ports (5555, 5252).  Most of the properties in the returned object are populated, it is just those few that are throwing exceptions when accessing them.

Reply