通过SharePoint 2013或SPD2013将数据发送到SOAP服务



我有一个肥皂服务,该服务获取用户ID和资格代码,并在找到用户并将资格代码添加到其名称中,将返回布尔值(true)。在Visual Studio内部,我写一个简单的页面没有问题,该页面有2个文本框,我将这些信息从这些文本框中获取并将其提交给Web服务。我无法弄清楚如何在SharePoint或SharePoint Designer内部进行此操作,这两者都是2013年。我遵循这些指示将服务添加为数据源,但我不确定如何使用它。

总体项目是我有一个培训站点,当员工通过测试时,我想通过用户并将资格传递给SOAP Web服务,以在另一个环境中更新。是的,它是重复的信息,但这是公司想要的。SharePoint中的信息存储在列表中。

编辑因此,我认为我必须在参数框架中进行。如果我只是将位置更改为控件(TextBoxID),则假设这将使用这些文本框中的任何内容调用Web服务,但到目前为止还没有。

<parameterbindings>
        <ParameterBinding Name="userID" Location="Control(UserIDTB)" DefaultValue="domainuser"/>
        <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>

所以对我来说,我无法弄清楚,或者也许无法在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(superbuser) 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(superbuser) 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;
                }
            }
        }

    }
}

您需要连接到Web服务的其他两个项目,其中1个是要更改elements.xml文件的2,如果您只希望它在1列表上具有影响。

<!--<Receivers ListTemplateId="100">-->
  <Receivers ListUrl="Lists/Completed Training">

相关内容

  • 没有找到相关文章

最新更新