Saturday, 16.12.2017, 18:42
| RSS

Engineer M DevelopmentMA

Главная » 2013 » January » 12 » SharePoint on iOS - part 2
SharePoint on iOS - part 2
15:14



The first part here.

How to get all server subsites? The SharePoint server can have websites (subsites), example 'mobile': https://sp.company.com/mobile .
To receive it you have to use the method GetWebCollection from directory https://sp.company.com/mobile/_vti_bin/Webs.asmx (info - http://msdn.microsoft.com/en-us/library/webs.webs.aspx).

The request look like:
NSString *soapMessage = @"\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<GetWebCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n";

The response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetWebCollectionResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetWebCollectionResult>
<Webs>
<Web Title="Accounts" Url="https://sp.company.com/accounts" />
<Web Title="Mobile" Url="https://sp.company.com/mobile" />
<Web Title="Desktop" Url="https://sp.company.com/desktop" />
</Webs>
</GetWebCollectionResult>
</GetWebCollectionResponse>
</soap:Body>
</soap:Envelope>


Ok. How to get a field value of the Item from a List?
Items can be received via method GetListItems. This method has some placeholders:
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>string</listName>
      <viewName>string</viewName>
      <query>string</query>
      <viewFields>string</viewFields>
      <rowLimit>string</rowLimit>
      <queryOptions>string</queryOptions>
      <webID>string</webID>
</GetListItems>

- listName: is the Field ID or Name of a List, exists in the GetListCollection response. (example Name="{88299283-69DC-45B2-B4BF-4E5413ED4E50}", take a look at the first part of lesson);
- viewName: is the Name of View that provides methods for creating, deleting, or updating list views in SharePoint Services.
- query: is a schema of Collaborative Application Markup Language (CAML), uses for receive certain data of a List. (http://msdn.microsoft.com/en-us/library/ms467521.aspx)
- viewFields: is an enumeration of the Fields which you want to receive in the response. The Fields name gets through the GetListAndView method.
- rowLimit: to set a limit on Items in the response. Helps to make pagination.
- queryOptions: is a separate query properties. Effects on displaying data.
- webID: for defining a GUID of the parent Web site. Optional;

A simple request look like:
NSString *soapMessage = [NSString stringWithFormat:@"\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
"<listName>%@</listName>\n"
"</GetListItems>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n"
, listName];


The response:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetListItemsResponse
xmlns="http://schemas.microsoft.com/sharepoint/soap/"><GetListItemsResult><listitems
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
     xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
     xmlns:rs='urn:schemas-microsoft-com:rowset'
     xmlns:z='#RowsetSchema'>
<rs:data ItemCount="2">
   <z:row ows_ID='1' ows_ContentType='Contact' ows_Title='Test 01'
ows_Modified='2013-01-10 11:22:30' ows_Created='2013-01-10 11:22:30'
ows_Author='2;#administrator' ows_Editor='2;#administrator'
ows__UIVersionString='1.0' ows_Attachments='0'
ows_Comments='&lt;div&gt;&lt;/div&gt;' ows__ModerationStatus='0'
ows__Level='1' ows_UniqueId='1;#{E98A638B-FA05-4946-BC54-5040036A688B}'
ows_FSObjType='1;#0' ows_MetaInfo='1;#' ows_owshiddenversion='1'
ows_FileLeafRef='1;#1_.000' ows_PermMask='0x1b03c4312ef'
ows_FileRef='1;#mobile/Lists/ContactTest/1_.000' />
   <z:row ows_ID='2' ows_ContentType='Contact' ows_Title='Test 02'
ows_Modified='2013-01-10 12:32:28' ows_Created='2013-01-10 12:32:28'
ows_Author='2;#administrator' ows_Editor='2;#administrator'
ows__UIVersionString='1.0' ows_Attachments='0'
ows_Comments='&lt;div&gt;&lt;/div&gt;' ows__ModerationStatus='0'
ows__Level='1' ows_UniqueId='2;#{26ACC5E9-105D-422A-91A3-F7FC94A5F522}'
ows_FSObjType='2;#0' ows_MetaInfo='2;#' ows_owshiddenversion='1'
ows_FileLeafRef='2;#2_.000' ows_PermMask='0x1b03c4312ef'
ows_FileRef='2;#mobile/Lists/ContactTest/2_.000' />
</rs:data>
</listitems></GetListItemsResult></GetListItemsResponse></soap:Body></soap:Envelope>


The response data contains two Items (ItemCount="2"), every Item begin with the node '<z:row .../>' . This node contain default attributes (Fields name). 
Example ows_ID='2': 
ows_ID is an attribute;
ID is a Field name;
'2' is a value;

All attributes has the prefix 'ows_', which you can remove before to add in array.
In the '' symbol exist value of Field, it's you have to display to users. By default an Item doesn't contain all Fields, which you can see via HTML website in a browser.
To get certain Fields of an Item you have to define a placeholder <viewFields>string</viewFields> . The Fields name you can take from the method GetListAndView. 

The SOAP request look like:
NSString *soapMessage = [NSString stringWithFormat:@"\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<GetListAndView xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
"<listName>%@</listName>\n"
"<viewName></viewName>\n"
"</GetListAndView>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n"
, listName];


This response contains a more information about a List and View. In the List data exist description of Fields, List properties and regional settings. The View data describes a view mode properties, defined Fields, limits by rows and query for data displaying.
Example you can find in this topic http://msdn.microsoft.com/en-us/library/lists.lists.getlistandview.aspx . The enumerations of Fields contains in the node <Fields>:
<Fields>
<Field
 ID="{64cd368d-2f95-4bfc-a1f9-8d8434ecb017}" ColName="tp_ID" ReadOnly="TRUE" Type="Counter" Name="ID" Hidden="TRUE" PrimaryKey="TRUE" DisplayName="ID" FromBaseType="TRUE" />
<Field ID="{64cd368d-2f95-4bfc-a1f9-8d4005ecb087}" Type="Text" Name="Title" DisplayName="Title" Required="TRUE" FromBaseType="TRUE" ColName="nvarchar1" />
<Field ID="{64cd368d-2f95-4bfc-a1f9-8d4324ecb777}" Type="Lookup" DisplayName="Parent" Required="FALSE" EnforceUniqueValues="FALSE" List="{b007aaf4-9de1-4694-b449-0ea5bf31d2b5}" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" RelationshipDeleteBehavior="None" ID="{87e663ef-9188-4a08-868d-b41060acb713}" SourceID="{aeaca6d9-984b-459f-98f8-9072c20ab599}" StaticName="Parent" Name="Parent" ColName="int4" RowOrdinal="0" WebId="8cf353a9-b786-4ea2-96fe-9744c2e99196" Version="1"/>
<Field ID="{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}" Type="DateTime" Name="StartDate" DisplayName="Begindate" Format="DateOnly" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="StartDate" ColName="datetime1"><Default>[today]</Default><DefaultFormulaValue>2013-01-13T00:00:00Z</DefaultFormulaValue></Field>
<Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Type="Note" RichText="FALSE" Name="Body" DisplayName="Description" Sortable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body" ColName="ntext2" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" NumLines="6" RestrictedMode="TRUE" RichTextMode="Compatible" IsolateStyles="FALSE" AppendOnly="FALSE" Version="1" RowOrdinal="0"/>
<Field ID="{d2311440-1ed6-46ea-b46d-daa643dc3886}" Type="Number" Name="PercentComplete" Percentage="TRUE" Min="0" Max="1" DisplayName="% complete" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="PercentComplete" ColName="float1"/>
<Field ID="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" ColName="tp_Modified" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" Name="Modified" DisplayName="ModifiedDate" StorageTZ="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified" FromBaseType="TRUE"/>
<Field ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}" ColName="tp_Created" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" Name="Created" DisplayName="CreateDate" StorageTZ="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Created" FromBaseType="TRUE"/>
<Field ID="{1df5e554-ec7e-46a6-901d-d85a3881cb18}" ColName="tp_Author" RowOrdinal="0" ReadOnly="TRUE" Type="User" List="UserInfo" Name="Author" DisplayName="Created by" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Author" FromBaseType="TRUE"/>
...
</Fields>


This Fields response from my SP server and has more rows of data. I picked Fields by types. Some of them are understandable by name, others example: 
Lookup - is a listing of values from another List ID ( the data defined in the next attributes List="{b007aaf4-9de1-4694-b449-0ea5bf31d2b5}" ShowField="Title" );
DateTime - is a date and time value, it can be formatting via attribute Format="DateOnly" or "TimeOnly". This field has default value, that defined via the node <Default>. It's can have another Fields.;
User - is users which exist on the server.
If you want to add info about Item changes, the data contain Fields Created (created date), Modified (modified date), Author (created by author).
The Field contains necessary attributes which describe Name, Display name, Type, ID, Read only, Required, Hidden, Data formatting, Value, Source value. By these properties you can choose preferred Fields or create own query.
For filling the node <viewFields>string</viewFields> you have to parse the 'Name' attribute and don't need to add a prefix 'ows_'. The node can collect so:
[soapMessage appendFormat:@"<viewFields>\n<ViewFields>\n"];
for(Field *f in fieldList)
{
        [soapMessage appendFormat:@"<FieldRef Name='%@' />\n",f.name];
}    
[soapMessage appendFormat:@"</ViewFields>\n</viewFields>\n"];


For displaying correctly the Field, will be good to use attribute DisplayName. It can contain already translated name (like as on the WebSite) or more grammatically

Now you know how to receive fields and values of Item.

Категория: Lessons | Просмотров: 6889 | Добавил: admin | Рейтинг: 5.0/1 |
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Меню сайта
Разделы новостей
Concept Software [2]
Programs are planned or under construction.
Software [10]
Release Software
Lessons [12]
About Me [1]
Infa about yourself, documents, certificates ...
Documentation [4]
Documentation of projects
Календарь новостей
«  January 2013  »
SuMoTuWeThFrSa
  12345
6789101112
13141516171819
20212223242526
2728293031
Поиск
Друзья сайта
Статистика
Copyright Macarov Anatoli © 2017
Free website builderuCoz