Programming in Visual Studio with Service Provider Foundation Services

 

Applies To: System Center 2016 - Service Provider Foundation, System Center Technical Preview

You can use Microsoft Visual Studio 2010 Service Pack 1 (SP1), Visual Studio 2012, or Visual Studio 2013 to develop applications and resources with Service Provider Foundation and Windows Azure Pack for Windows Server.

Prerequisites

WCF Data Services 5.6.0 should be used when coding with Service Provider Foundation or Windows Azure Pack. If you have never installed the WCF Data Services 5.6.0 tools, you must do this on your development computer first. The tools installer is available at the Microsoft Download Center. After you have installed the tools and have opened up a project in Visual Studio, you should update or install the latest WCF Data Services NuGet package for your projects. The WCF Data Services NuGet packages do not include the client code generation tools provided by the WCF Data Services installer downloaded from the Microsoft Download Center. For more information, seeWCF Data Services NuGet and WCF Data Services Blog.

Depending on your client platform, you may not be using Visual Studio as your development IDE, or a .NET programming language. For more information about the available OData client libraries that may work with your platform, see the Open Data Protocol libraries page.

All example URLs use the Service Provider Foundation URI conventions. Unless they are specified otherwise, they do not use the RDFE conventions. For more information, seeSPF and RDFE URIs.

Assumptions

The examples in this Developer’s Guide generally assume that you know the uniform resource identifier (URI) that is required to connect to the Service Provider Foundation web service, and that a connection has been made to the server. For more information about how to construct the URI, see Service Provider Foundation Services and OData Protocol.

The code examples in this Developer’s Guide were developed in Visual Studio 2012, and they target the Microsoft .NET Framework 4.

The examples in this Developer’s Guide use the following variable names for namespaces and instantiated classes:

SpfVMM
Namespace of the VMM service

SpfAdmin
Namespace of the Administration service

vmmService
Virtual Machine Manager service variable name

adminService
Administration service variable name

Connecting to Service Provider Foundation

The following procedures describe how to start developing by using the Service Provider Foundation service.

To add a service reference to a Visual Studio project

  1. Open or create a new Visual Studio project.

  2. In the Solution Explorer window, right-click the References folder, and then click Add Service Reference.

  3. In Address, type the address of the Service Provider Foundation service that you want to connect to.

  4. To load the available services, click Go.

  5. In Namespace, type a display name for the namespace.

  6. Click OK.

To establish a connection to a Service Provider Foundation service

  1. Create a new instance of the SpfService.VMM class. Pass the URI of the service to the constructor of this class.

    Note

    This procedure assumes that a service was added to Service References with the namespace of SpfService and that the VMM service is used.

  2. With reference to the SpfService.VMM class instance, set the Credentials property to System.Net.CredentialCache.DefaultNetworkCredentials.

    Tip

    As an alternative, you can set the Credentials property to a new instance of the System.Net.NetworkCredential class and provide a specific user account.

  3. When an operation on the SpfService.VMM object instance is performed, such as adding an object to a collection or reading a list of objects from a collection, the connection to the server is established.

See Also

Getting Started
Release Notes for Service Provider Foundation 2012 SP1
Release Notes for Service Provider Foundation 2012 R2