A

Answers To Exercises

CHAPTER 1 ANSWERS TO EXERCISES

Exercise 1 Solution

For the end user and the developer, SharePoint is a Web-based collaboration platform for the enterprise and Web. As an end user, you will natively leverage SharePoint to manage your collaborative tasks. As a developer, you will build apps to enhance the end user’s experience to help support different types of scenarios.

Exercise 2 Solution

You can use default SharePoint apps, such as document libraries, lists, and so on. And you can build custom Apps for SharePoint, such as Web parts, event receivers, workflow apps, and so on.

Exercise 3 Solution

Excel Services, Business Connectivity Services, Machine Translation Services, and Access Services are examples.

Exercise 4 Solution

Server-side object model and client-side object model. You use the server-side object model when building applications in SharePoint Server or SharePoint Foundation. You can use the client-side object model for any version of SharePoint.

Exercise 5 Solution

Work through creating a new site collection using the exercises in the chapter to help guide you. Navigate to your SharePoint administration page and click New ⇒ Private Site Collection. Complete the information in the New Site Collection dialog and as you do, ensure you select the Team Site template in the Collaboration tab. Click OK to create, and once created you can click Site Contents to add lists, document libraries, and other apps.

CHAPTER 2 ANSWERS TO EXERCISES

Exercise 1 Solution

SharePoint-hosted, Autohosted, and Provider-hosted.

Exercise 2 Solution

Any Web stack.

Exercise 3 Solution

You can find an example of this in the SharePoint 2013 SDK. See Chapter 2, “Recommended Reading.”

CHAPTER 3 ANSWERS TO EXERCISES

Exercise 1 Solution

Visual Studio, SharePoint Designer, and Napa. You can also use tools like Expression Blend for rich design and Fiddler for debugging and tracing.

Exercise 2 Solution

You would use Visual Studio for managed code development and development that requires ALM or source code control. Napa is for rapid development and prototyping — but the code can also be imported into Visual Studio. You use SharePoint Designer for creating, editing and updating Web pages, content types, and so on. You can also use SharePoint Designer for creating rules-based workflow.

Exercise 3 Solution

Open Visual Studio, and click File ⇒ New Project. Select the Empty SharePoint Project template and then add a SharePoint site URL and select Farm-Level trust for your project. Then, Add a web part project to your empty SharePoint project. Add some simple controls to your Web Part, and then add a breakpoint somewhere in your newly added code. Enter F5 to test and debug the code.

CHAPTER 4 ANSWERS TO EXERCISES

Exercise 1 Solution

Using Visual Studio 2012, you can create an Empty SharePoint project. Using the Empty SharePoint project as a shell project, you can then add two items to the project: a Standard Web Part and a Visual Web Part. After you’ve done this, add the code from this chapter to create the simple Web Parts. You can hit F6 to build the project, and then deploy the project to your SharePoint site. Both of your Web Parts will be deployed to your SharePoint site, and you’ll be able to use them separately.

Exercise 2 Solution

You can continue to use the SharePoint project that you used in the first exercise (the project to which you added the two Web Parts), or you can create a new one. Either way, add a new item that is an ASPX Page and then add some simple HTML to the page (for example, <DIV>Hello World!</DIV>). After you’ve completed this, hit F6 to build the project and then deploy to SharePoint.

Exercise 3 Solution

You can create your own Master Page, or you can download a Minimal Master Page or Starter Master Page. The Minimal Master Page is the most basic Master Page that you can use with SharePoint. You can find information about how to create a Minimal Master Page here: http://msdn.microsoft.com/en-us/library/aa660698(v=office.12).aspx. A Starter Master Page has some additional elements beyond the Minimal Master Page, and these are typically created by the SharePoint community. One example is here: http://startermasterpages.codeplex.com/. Once you’ve downloaded either of these, use SharePoint Designer to create a new Master page, copy and paste the contents of either the minimal or starter page, and then save to your SharePoint site. You can then set the new Master page as the default Master Page using SharePoint Designer, and your new Master page will take effect.

CHAPTER 5 ANSWERS TO EXERCISES

Exercise 1 Solution

IAAS, PAAS, and SAAS.

Exercise 2 Solution

Cloud Services, Media Services, Data Services, Web Sites, Data Sync, Hadoop on Azure.

Exercise 3 Solution

Autohosted and Provider-hosted.

Exercise 4 Solution

First, create a new SharePoint project (targeting an Office 365 Developer site) and set the project to be Autohosted as you create the project. This provides you with the basic plumbing of an ASP.NET application that you can natively deploy to Office 365 (and of course Windows Azure). After you’ve created the Autohosted application, you can leverage the REST service project you built at the beginning of Chapter 5 or recreate it within the same solution you just created. Either way, deploy the REST service to Windows Azure. After you’ve deployed, you now have a REST endpoint that you can call to use the data that is returned from that service endpoint. You can now add a simple Button control and event to call the REST service to show that you can retrieve the data. Keep it simple to understand the data structure that is returned, such that you can build out the application to leverage the data.

CHAPTER 6 ANSWERS TO EXERCISES

Exercise 1 Solution

The new SharePoint application model removes code from running within the core SharePoint processes and moves it externally to another host. The new model provides the APIs for authenticating and calling back to SharePoint for data and responding to events.

Exercise 2 Solution

The SharePoint application model provides the following three areas for integration:

  • User Interface
  • Data
  • Events

Exercise 3 Solution

A Web Part’s code is run and rendered by code running in the SharePoint process. An App Part is an iFrame whose contents are rendered on another server.

Exercise 4 Solution

An application’s permissions are granted when the application is installed. The user installing the application may accept or decline the invitation to grant the permissions the app is asking for.

Exercise 5 Solution

SharePoint applications can use the provided “Chrome Control” and reference provided style sheets to adopt the same visual styling as SharePoint sites.

CHAPTER 7 ANSWERS TO EXERCISES

Exercise 1 Solution

The four main components of an .app package are the manifest file, the SharePoint solution, the Web deploy package and the database package.

Exercise 2 Solution

In a Provider-hosted application the developer of the application is responsible for running the application code himself. This means the SharePoint application package contains the SharePoint solution and manifest only. The code portion of the solution runs wherever the developer hosts it, such as in Azure.

Exercise 3 Solution

Only two types of components are allowed to be deployed to the host Web during installation of an app: App Parts and Custom UI Actions.

CHAPTER 8 ANSWERS TO EXERCISES

Exercise 1 Solution

Provider-hosted apps need a manually created client ID and secret prior to submission to the store so that the developer can add them to the application’s back-end code so that the app is running when it is tested by Microsoft.

Exercise 2 Solution

There are many options for monetizing applications. However, some of the most common are to make the application a paid for product through the store, add ads to the application, and sell in-app purchases in the application.

Exercise 3 Solution

An application can catch any of the following application life-cycle events: App Installed, App Uninstalling, or App Upgraded.

CHAPTER 9 ANSWERS TO EXERCISES

Exercise 1 Solution

The three types of CSOM libraries are: .NET Managed, JavaScript and Windows Phone/Silverlight.

Exercise 2 Solution

OData adds additional filter and query capabilities over and above what is available with the standard REST capabilities.

Exercise 3 Solution

REST and OData support in SharePoint 2013 provides support for Creating, Reading, Updating, and Deleting data.

Exercise 4 Solution

By using the provided CSOM libraries, developers can take advantage of the prebuilt batching capabilities to reduce the number and frequency of calls made to SharePoint.

CHAPTER 10 ANSWERS TO EXERCISES

Exercise 1 Solution

Using either SharePoint Online or SharePoint on premises you can create new application identities using the AppRegNew.aspx page.

Exercise 2 Solution

The three token types used in SharePoint’s OAuth flow are the context token, access token and refresh token.

Exercise 3 Solution

When needed, an application may elevate its permissions to those of just the application by using the GetAppOnlyAccessToken helper method to generate an app-only access token.

Exercise 4 Solution

The refresh token and access tokens can both be cached. The period for which they can be cached should be determined by looking at the expiry date and time passed back from SharePoint for each.

CHAPTER 11 ANSWERS TO EXERCISES

Exercise 1 Solution

Apps for Office can be written using standard Web technologies hosted on any platform and written in any language.

Exercise 2 Solution

The new JSOM for Office allows the developer’s Web application to interact with the document or mail item, but does not provide for automation of the Office client.

Exercise 3 Solution

MailApp, TaskPaneApp, and ContentApp.

Exercise 4 Solution

You can use various strategies enabled by a number of methods on the Office.context.document.bindings object such as .addFromSelectionAsync, .AddFromPromptAsync, and .AddFromNamedItemAsync.

CHAPTER 12 ANSWERS TO EXERCISES

Exercise 1 Solution

ProcessOneWayEvent

Exercise 2 Solution

Enumeration, .CancelWithError and property, and .ErrorMessage.

Exercise 3 Solution

S2S and OAuth.

Exercise 4 Solution

You can actually look in two places. One is in the manifest file, and the other is checking to see whether any one of the app life-cycle properties of the SharePoint project is set to True.

CHAPTER 13 ANSWERS TO EXERCISES

Exercise 1 Solution

OData.

Exercise 2 Solution

CSOM or REST.

Exercise 3 Solution

EventSubscriber and EventUnsubscriber.

Exercise 4 Solution

ECTs can now be deployed as part of an app for SharePoint at the app-level whether the app is Provider-hosted, Autohosted, or SharePoint-hosted.

CHAPTER 14 ANSWERS TO EXERCISES

Exercise 1 Solution

PowerPoint Automation Services and Machine Translation Services.

Exercise 2 Solution

The Office Web App Server.

Exercise 3 Solution

OData.

Exercise 4 Solution

For an on-premises installation of SharePoint, the data and content are stored in a SQL Server database and for Office 365 they are stored in a Windows Azure SQL Database.

CHAPTER 15 ANSWERS TO EXERCISES

Exercise 1 Solution

The Service Bus provides durability for event delivery and for messaging using its Pub/Sub pattern.

Exercise 2 Solution

The App Step action lets the workflow elevate its permissions to perform something on behalf of the user with its own permissions.

Exercise 3 Solution

The Dictionary type variable.

Exercise 4 Solution

GetCurrentItemGuid.

image

For my wife.

—Steve Fox

For the delights of my life, Heather, Courtenay, and Morgan.

—Donovan Follette

For the loves of my life, Vicki, Sam, and Kate.

—Chris Johnson

ABOUT THE AUTHORS

image

STEVE FOX is a Director in MCS for Microsoft with more than 17 years of IT experience ranging from natural language to Office and SharePoint and most recently to Windows Azure development. His current focus is enabling the cloud for enterprise organizations.

image

DONOVAN FOLLETTE is a Sr. Technical Evangelist for Microsoft with more than 25 years of experience designing and building enterprise business applications. His current focus is on developers and helping them wrap their mind around the all-new cloud app model for Office and SharePoint 2013.

image

CHRIS JOHNSON is an avid developer and a speaker. He is the General Manager of Provoke Solutions, Inc. and a Microsoft Gold Partner in Seattle, Washington, that is one of the world’s most renowned and sought-after online experience consultancies. Provoke Solutions specializes in software solutions for SharePoint and the Microsoft technology stack (http://www.provokesolutions.com). In November 2011, Chris left Microsoft Corporation after nine and a half years where he most recently was a Senior Technical Product Manager for the SharePoint product group in Redmond, Washington, managing SharePoint’s professional developer audience technical marketing programs. Chris moved to Redmond in 2007 to work on the software engineering team on the SharePoint 2010 release after working for Microsoft New Zealand. In New Zealand he consulted for customers across the Asia Pacific region on designing and implementing Content Management Server and SharePoint deployments. Chris’s background is in Microsoft software development and he enjoys all things technical. He is a speaker at numerous conferences around the world such as Tech.Ed, SharePoint Best Practices Conference, SharePoint Connections, and the worldwide SharePoint Conference. Chris holds a Bachelor of Computer Science and enjoys throwing himself out of perfectly good airplanes from time to time. Contact Chris on his blog at www.looselytyped.net.

ABOUT THE TECHNICAL EDITOR

image

ANDREW CONNELL is a developer, author, instructor, and co-founder of Critical Path Training, a SharePoint education–focused company. He has a background in content management solutions and Web development that spans back to his time as a student at the University of Florida in the late 1990s managing class sites. He has consistently focused on the challenges facing business today to maintain a current and dynamic online presence without having to rely constantly on Web developers or have a proficiency in Web technologies.

Andrew is an eight-time recipient of Microsoft’s Most Valuable Professional (MVP) award (2005–2012) for Microsoft Content Management Server (MCMS) and Microsoft SharePoint Server. He has authored and contributed to numerous MCMS and SharePoint books over the years, including Professional SharePoint 2007 Web Content Management Development (Wrox, 2008), Inside Microsoft SharePoint 2010 (MSPress, 2011) and (Wrox, 2010), and Real World SharePoint 2010 (Wrox), among others, and is the author of numerous articles both for the Microsoft Developer Network (MSDN) and for various magazines.

Andrew has presented at numerous conferences in the United States, Europe, and Australia. You can find Andrew on his blog (www.andrewconnell.com/blog) or follow him on Twitter @andrewconnell.

CREDITS

Acquisitions Editor

Mary James

Project Editor

Victoria Swider

Technical Editor

Andrew Connell

Production Editor

Christine Mugnolo

Copy Editor

Paula Lowell

Editorial Manager

Mary Beth Wakefield

Freelancer Editorial Manager

Rosemarie Graham

Associate Director of Marketing

David Mayhew

Marketing Manager

Ashley Zurcher

Business Manager

Amy Knies

Production Manager

Tim Tate

Vice President and Executive Group Publisher

Richard Swadley

Vice President and Executive Publisher

Neil Edde

Associate Publisher

Jim Minatel

Project Coordinator, Cover

Katie Crocker

Proofreader

Sarah Kaikini, Word One New York

Indexer

Robert Swanson

Cover Designer

Elizabeth Brooks

Cover Image

© Stefano Borsani / iStockphoto

ACKNOWLEDGMENTS

FIRST, thanks to the acquisitions and editorial staff at Wiley. It’s great to continue to work with such a good crew of people. Next, thanks to Andrew Connell for helping steer us in the right direction through technical editing. Also, thanks to Victoria Swider who tirelessly moved us through the editing and production process. Additionally, thanks to the many Microsoft folks who gave their time for technical questions and conversations. And last, thanks to you, the developer community. Without you, this book would not even be possible.

—Steve Fox

THANKS to Andrew Connell, technical editor, for providing his technical expertise and insight and Victoria Swider, project editor, for her patience as the authors juggled busy travel and conference schedules to find time-slices for writing. I would also like to acknowledge my Microsoft colleagues whom I learned much from as Office and SharePoint 2013 were taking shape: Mauricio Ordonez, Rob Howard, Mike Ammerlaan, Rolando Jimenez Salgado, Gareth Pinto, Stephen Oliver, and Brady Gaster. You are all a pleasure to work with and greatly respected. And thanks to you, the reader, My hope is that this book will introduce you to the opportunity for developing a new class of productivity solutions in the form of Apps for Office and SharePoint, and that your solutions, whether built and provided behind the firewall or installed from Office.com, will find their way into the hands of the all-important end users, whose day will be a bit better because they are using your software. Enjoy!

—Donovan Follette

THANKS must go out to our wonderful editors and staff at Wiley for ushering me through my first technical book project. Their patience and flexibility were invaluable given the authors’ hectic day jobs, speaking engagements, and travel schedules. I know at times it was like herding cats! A huge debt of gratitude to the one and only Andrew Connell who provided the elite technical air cover and expertise to keep us all on the straight and narrow and accurate! Thanks to Nick Swan and the team at Lightning Tools for their insights into real-world SharePoint application metrics. Finally, to all the folks at Microsoft who assisted with answering questions, providing support, and generally being really helpful as I wrote this book — Thank you all.

—Chris Johnson

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset