【问题标题】:Sending Data to Soap Service by SharePoint 2013 or SPD2013通过 SharePoint 2013 或 SPD2013 将数据发送到 Soap 服务
【发布时间】:2017-02-20 15:20:05
【问题描述】:

我有一个 SOAP 服务,它接受一个 USERID 和一个资格代码,如果找到用户并将资格代码添加到他们的名称中,则返回一个布尔值 (true)。在 Visual Studio 中,我可以毫无问题地编写一个包含 2 个文本框的简单页面,我从这些文本框中获取信息并将其提交给 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>

【问题讨论】:

    标签: web-services sharepoint soap sharepoint-2013


    【解决方案1】:

    所以对我来说,我无法弄清楚,或者在 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 是更改 Elements.xml 文件,如果您只希望它对 1 个列表产生影响。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      相关资源
      最近更新 更多