我有一个SOAP服务,它接受一个用户I和一个限定代码,如果找到用户并将限定代码添加到他们的名字中,返回一个布尔值(True)。在Visual中,我没有问题编写一个简单的页面,其中有两个文本框,我从这些文本框中获取信息并将其提交给web服务。我不知道如何在SharePoint或SharePoint设计器中实现这一点,这都是2013年的事。我跟随这些方向添加了作为数据源的服务,但是我不确定如何使用它。
总体项目是我有一个培训站点,当员工通过测试时,我希望将用户和资格证书传递给SOAP服务,以便在另一个环境中进行更新。是的,这是复制的信息,但这是公司想要的。SharePoint中的信息存储在列表中。
编辑,所以我想我必须用ParameterBindings来做。如果我只是将位置更改为Controls(textboxid),我假设这将使用这些文本框中的任何内容调用web服务,但到目前为止还没有。
<parameterbindings>
<ParameterBinding Name="userID" Location="Control(UserIDTB)" DefaultValue="domain\user"/>
<ParameterBinding Name="qualificationCode" Location="Control(QualCode)" DefaultValue="PIT"/>
<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
<ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
</parameterbindings>发布于 2017-02-23 19:35:31
因此,对我来说,我不知道,或者也许不可能在SharePoint设计器中做到这一点。我必须在Visual中创建一个事件接收器,它连接到SOAP服务,然后将数据从我的列表发送到该服务。完整的代码如下。我怀疑我需要所有的补充在顶部,但我只是离开了他们,因为它是有效的。
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
namespace CompletedTraining.TrainingCompleteListener
{
/// <summary>
/// List Item Events
/// </summary>
public class TrainingCompleteListener : SPItemEventReceiver
{
/// <summary>
/// An item was added.
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
{
//Item was just added to the list
base.ItemAdded(properties);
using (SPWeb web = properties.OpenWeb())
{
try
{
//get the item that was just added
SPListItem currentItem = properties.ListItem;
//create a new connection to the NavSoapService
NAVSoapService.EmployeeQualificationMgt service = new NAVSoapService.EmployeeQualificationMgt();
//Use the default credentials for this service
service.Credentials = CredentialCache.DefaultCredentials;
//convert the Name field from the list to a string we'll use to pass to the NavSoapService. We need the username(superb\user) instead of just name(first last) the next 3 lines do this conversion
string nameField = currentItem["Name"].ToString();
SPFieldUserValue userField = (SPFieldUserValue)currentItem.Fields["Name"].GetFieldValue(nameField);
SPUser user = userField.User;
//Once we have user id we need to get their login name(superb\user) and remove the 7 junk characters to the left
string loginName = (user.LoginName).Substring(7);
//Call the service with the login name and the Qualification code store the result in the result variable.
bool result = service.AddEmployeeQualification(loginName, (string)currentItem["Qualification Code"]);
//write the result in the Uploaded to NAV column
currentItem["Uploaded to NAV"] = result;
//update the current item in the list.
currentItem.Update();
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}在您的项目中还需要另外两项,即1项,您需要连接到Web,2项是更改Elements.xml文件,如果您只希望这对1列表有影响的话。
<!--<Receivers ListTemplateId="100">-->
<Receivers ListUrl="Lists/Completed Training">https://stackoverflow.com/questions/42348224
复制相似问题