1

I created a SmartObject in K2 designer and I added the WCF url as service reference.

Below is the code

UserDetailsSvcClient userDetail = new UserDetailsSvcClient();
userDetail.Open();
UserDetails userDC = new UserDetails();
var userDetailsList = userDetail.UserDetailsSvc_Load(userDC);
userDetail.Close();

But the userDetailsList always remains as null.

Also the GetList Smart method is not appearing

4

2 回答 2

1

我将假设您已在 K2 服务器上启用了端点。如果没有,请参考下面的链接到端点创建 PS:您需要重新启动 K2 Server 才能使更改生效。

从代码来看,您似乎正在尝试执行 Load 方法。加载方法将需要一个 ID。

因此对于 UserDetails userDC = new UserDetails();,添加以下内容:

userDC.Id = 1;

对于 GetList,您不需要将 UserDetails 对象传递给它。

var userDetailsList = userDetail.UserDetailsSvc_GetList(Null);
于 2016-03-09T01:06:16.113 回答
0

问题是我没有授权客户。我需要添加

userDetail.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

所以最后代码看起来像这样

UserDetailsSvcClient userDetail = new UserDetailsSvcClient();
    userDetail.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

userDetail.Open();
UserDetails userDC = new UserDetails();
var userDetailsList = userDetail.UserDetailsSvc_Load(userDC);
userDetail.Close();
于 2016-07-08T08:08:15.937 回答