jQuery Call web services(SOAP) in SharePoint 2013
来源:互联网 发布:ip网络广播 编辑:程序博客网 时间:2024/06/04 18:41
Step by Step Calling web services(SOAP) in SharePoint 2013
As we know sharepoint already provide some sevice for user, we needn't write CAML to query list every time, sharepoint web service have enough methods, it is easy and fast, suggest to call sharepoint serivice.
1. This time, we will analysis the web service using SOAP, and learn how to call the web service in client. here is a web service file:http://servername/_vti_bin/Lists.asmx, and detail:
2. Click a link and show the method in detail, notice the soap envelope.
3. now, we start to coding: we will use the GetList method in this sevice to return the list itmes count with jQuery .
a. Create a custom list name hr, and add some data to test.
- b. The main code is set the soap envelope and get the respond body with posting request. then we can get the detail info in the respond body via F12 in IE. because this is xml file, it support jQuery seletor.
- c. Here is the code in all:
<script type="text/javascript"> var isIE = (navigator.appName.toLowerCase().indexOf('netscape') == -1); $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(makeSoapCall, 'sp.js');});function makeSoapCall(){ var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema' \ xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \ <soap:Body> \ <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \ <listName>" + "hr" + "</listName> \ <viewName></viewName> \ <query></query> \ <viewFields></viewFields> \ <rowLimit></rowLimit> \ <queryOptions><QueryOptions xmlns=''><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><ViewAttributes Scope='RecursiveAll'/></QueryOptions></queryOptions> \ </GetListItems> \ </soap:Body> \ </soap:Envelope>"; $.ajax({ url:"HTTP://DEV-SP/_vti_bin/Lists.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" });}function processResult(xData, status) { var result; if (isIE) result = xData.responseXML else result = xData.responseText try { if (status == "success" && result){ $(result).find("rs\\:data").each(function() { alert($(this).attr("ItemCount") + " Items found."); }); } } catch (e) { alert(e); }} </script>
- d. Result:
Links : Calling the SharePoint 2010 GetListItems web services with Jquery
0 0
- jQuery Call web services(SOAP) in SharePoint 2013
- Client Call SharePoint Web Service(SOAP)
- Call SOAP Web services with Ajax, Part 1: Build the Web services client
- Call SOAP Web services with Ajax, Part 2: Extend the Web services client
- Java SOAP Web services
- SOAP及Web Services
- PHP5 soap web services
- SOAP Web Services 简介
- Web Services in C, REST, SOAP and WS-*
- Using Reporting Services SharePoint Web Parts in SQL Server
- SharePoint Web Services入门
- SharePoint Web Services入门
- SharePoint Web Services入门
- SharePoint Open Web Services
- Using Reporting Services SharePoint Web Parts in SQL Server 2000 Reporting Services Service Pack 2
- Web Services Addressing - SOAP Binding
- Programming Web Services With SOAP
- REST vs SOAP Web Services
- 网址的收藏系列一
- 颜色转换
- Android之GPS定位详解
- 黑马程序员 C#学习笔记⑨ 序列化对象
- 《黑马程序员》 传统的定时器的创建方式总结与测试
- jQuery Call web services(SOAP) in SharePoint 2013
- BroadcastReceiver 网络状态变化
- 骗子电话
- Python爬虫初学(2)豆瓣电影top250评论数
- iOS 7 与 Xamarin - MultiPeer Connectivity (2)
- 改变edittext边框颜色
- Windows 驱动程序设计(二)
- Hibernate使用原生SQL适应复杂数据查询
- Translation in Magento shell script