我有一个SOAP服务,它接受一个USERID和一个Qualification Code,如果找到User并且在他们的名字中添加了Qualification Code,则返回一个布尔值(true)。在Visual Studio中我编写一个有两个文本框的简单页面没有问题,我从那些文本框中获取信息并将其提交给Web服务。我无法弄清楚如何在SharePoint或SharePoint Designer中执行此操作都是2013.我已按照these directions将服务添加为数据源,但我不确定如何使用它。
整个项目是我有一个培训站点,当员工通过测试时,我想将用户和资格传递给SOAP Web服务,以便在另一个环境中进行更新。是的,这是重复的信息,但它是公司想要的。 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>
答案 0 :(得分:0)
所以对我来说,我无法弄清楚,或者在SharePoint Designer中无法做到这一点。我必须在Visual Studio中创建一个连接到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是如果您只想要对1个列表产生影响,则更改Elements.xml文件。
<!--<Receivers ListTemplateId="100">-->
<Receivers ListUrl="Lists/Completed Training">