首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过SharePoint 2013或SPD2013向Soap服务发送数据

通过SharePoint 2013或SPD2013向Soap服务发送数据
EN

Stack Overflow用户
提问于 2017-02-20 15:20:05
回答 1查看 235关注 0票数 0

我有一个SOAP服务,它接受一个用户I和一个限定代码,如果找到用户并将限定代码添加到他们的名字中,返回一个布尔值(True)。在Visual中,我没有问题编写一个简单的页面,其中有两个文本框,我从这些文本框中获取信息并将其提交给web服务。我不知道如何在SharePoint或SharePoint设计器中实现这一点,这都是2013年的事。我跟随这些方向添加了作为数据源的服务,但是我不确定如何使用它。

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

编辑,所以我想我必须用ParameterBindings来做。如果我只是将位置更改为Controls(textboxid),我假设这将使用这些文本框中的任何内容调用web服务,但到目前为止还没有。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2017-02-23 19:35:31

因此,对我来说,我不知道,或者也许不可能在SharePoint设计器中做到这一点。我必须在Visual中创建一个事件接收器,它连接到SOAP服务,然后将数据从我的列表发送到该服务。完整的代码如下。我怀疑我需要所有的补充在顶部,但我只是离开了他们,因为它是有效的。

代码语言:javascript
复制
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列表有影响的话。

代码语言:javascript
复制
<!--<Receivers ListTemplateId="100">-->
  <Receivers ListUrl="Lists/Completed Training">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42348224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档