刚刚和同事讨论了一个关于在InfoPath中调用Web Service的问题。

需求: 我需要在InfoPath表单中通过输入用户名来获得用户的其他信息,例如:部门, 上级等等。 并且通过无代码的方式实现。

在Infopath 2010中调用Web Service

环境: SharePoint Server 2010, InfoPath 2010.

技术:

1. 在SharePoint Server 2010 中有一个 “User Profile Service Web service” 可以用来调用用户数据;

2. Infopath中可以添加 数据来接来读取外部的数据。

步骤:

1. 创建一个空的InfoPath 2010表单;

2. 添加两个字段(字符串类型),然后把基于字段的控件添加到InfoPath表单上;

3. 添加一个按钮;

4. 添加数据连接;

在Infopath 2010中调用Web Service

5. 输入 User Profile Web Service的地址 http://servername/_vti_bin/userprofileservice.asmx

在Infopath 2010中调用Web Service

6. 选择 “GetUserPropertyByAccountName” 方法

7. 有两个参数需要输入: “accountName” and “propertyName”. 我们暂时只为“propertyName” 字段指定一个默认值“Department”

在Infopath 2010中调用Web Service

8. 完成。

 

到现在为止,完成所有的步骤了吗?没有!我们还没有把Web Service的参数和InfoPath的控件联系起来。 在我的例子中查询操作是由button控件的”Rules“完成的。 所有,有三件事情需要button控件去做: 为表Web Service的参数赋值;查询; 获得返回参数;

在Infopath 2010中调用Web Service

9. 为button控件添加三个Rules;

在Infopath 2010中调用Web Service

a. Set a field’s Value: Field: accountName; Value: UserName

b. Query for Data:

c. Set a field’s value: Field: Department; Value: Value

10. 保存模板。

11. 你可以预览或者发布到SharePoint的表单库进行测试。

 

请确保当前的应用程序”没有启用匿名登录“否则,你将会得到如下的错误” Server was unable to process request. ---> Attempted to perform an unauthorized operation.”

在Infopath 2010中调用Web Service

Good luck.

相关文章:

  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2021-06-14
  • 2021-09-28
  • 2021-10-27
猜你喜欢
  • 2021-12-20
  • 2021-05-25
  • 2021-08-31
  • 2021-12-13
  • 2022-01-02
  • 2021-10-26
相关资源
相似解决方案