Export (0) Print
Expand All

4 Protocol Examples

SharePoint

The following examples illustrate how a protocol client retrieves and updates data on a protocol server by using this protocol. The example scenario is a book store that has a catalog of books. Each book within that catalog has an identifier, title, author, and status.

In this scenario, the following CSOM types are defined on the protocol server:

CSOM type

CSOM type name (identifier)

Description

Properties

Methods

BookStore

SampleCode.BookStore (acc57e47-24b0-4400-b1c7-aa1cf3c9542d)

A CSOM Object type that defines the book store, which contains a catalog.

Catalog – A Catalog type that contains a static property specifying a catalog of books.

None.

Catalog

SampleCode.Catalog (04a81e1b-a5b9-445d-97c0-681fe3f61189)

A CSOM Object type that defines the catalog, which contains a collection of books.

Books – A list of books.

None.

BookCollection

SampleCode.BookCollection (4c456811-3967-4021-8d9f-237ebd9c1170)

A CSOM Object type that defines a collection of books within a catalog.

None.

Add – Returns a Book type and adds a book to the collection. The only parameter is a BookCreationInformation object, which contains the title, author, publish date, and status of a book.

GetById – Returns a Book type that represents the book with the specified book identifier. If the book does not exist, the protocol server returns CSOM null. The only parameter is a CSOM GUID that contains the book identifier of the book.

The BookCollection type supports OData InsertEntity request as specified in [MS-ODATA] section 2.2.7.1.1 to add a book to the collection.

Book

SampleCode.Book (030f9ac0-5f2b-4422-9e32-bcdfc1a0c93a)

A CSOM Object type that defines a specific book in a collection of books.

Author – A CSOM String that contains the name of the author of the book.

Id – A CSOM String value that contains the identification number for the book.

PublishDate – A CSOM DateTime value that contains the date when the book was published.

Status – A Status type that contains the status of the book.

Title – A CSOM String that contains the title of the book.

Update – Updates information about the book by saving the property values that are currently set for the book. This method does not define any parameters.

CheckOut – Checks out the book for a user. This method has only one parameter, which is the user’s name. The return value of the CheckOut method is the date that the book is due.

The Book type supports OData UpdateEntity Request as specified in [MS-ODATA] section 2.2.7.3.1 to update information about the book.

BookCreationInformation

SampleCode.BookCreationInformation (dda98aeb-f87d-490f-9a61-be08644ad461)

A CSOM value object type that contains information about a book to be added to the catalog for the book store.

Author – A CSOM String that contains the name of the author of the book.

PublishDate – A CSOM DateTime value that contains the date when the book was published.

Status – A Status type that contains the status of the book.

Title – A CSOM String that contains the title of the book.

None.

Status

A CSOM enumeration type that specifies whether a book is in stock. If a book is in stock, this value is "0" (zero). If a book is out of stock, this value is "1". If a book is on back order, this value is "2".

None.

None.

In the examples, the catalog contains the following books.

Identifier

Title

Author

Status

Publish date

3387ac63-e73d-421f-bff7-359a4aa2bc38

How to Cook Chinese Food

Soha Kamal

0

March 1, 2008

f6a265ab-86e5-4fbf-937c-49923604b91d

How to Cook Japanese Food

Soha Kamal

1

May 5, 2007

2e80eb25-b64a-4506-b87b-2fff6ddb3f57

Best Recipes

Lisa Andrews

0

January 3, 2009

704655a3-c136-469c-a578-f79652a93f9b

Family Recipes

Patrick Hines

0

December 1, 2005

Show:
© 2014 Microsoft