Creating .NET Applications Using TPM OM REST API


Updated: November 27, 2015

Use the WCF Data Services to create .NET applications that consume the data services exposed by the TPM OM. The TPM OM API is based on the OData protocol. This topic provides instructions on how to create .NET applications to perform operations on the TPM OM entities, such as defining partners, creating agreements, and so on.

The following illustration captures a typical code flow for creating a .NET application to use the TPM OM REST API:

Typical code flow for using the REST API with .NET

To start creating .NET applications for consuming data services exposed by TPM OM API, install Visual Studio 2012 and WCF Data Services 5.0:

  • Install Visual Studio from

  • Install WCF Data Services from

  • If you used a self-signed certificate while provisioning Microsoft Azure BizTalk Services, you must add that certificate to trusted certificate store on the computer where you use the TPM OM API. Otherwise, you get error - The underlying connection was closed: Could not establish "trust relationship for the SSL/TLS secure channel. You do not need to perform this step if you used a certificate from a trusted signing authority.

This section lists the overall set of instructions that you must follow to create a .NET application using the TPM OM REST API. The instructions in this section assume that you create a C# application.

To create a C# application

  1. Create a Visual Studio C# project.

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

  3. In the Add Service Reference dialog box, do the following:

    1. For the address, enter the URL where the TPM OM service metadata is hosted and select Go. A typical URL for metadata looks like:$PartnerManagement

      In this URL, is your deployment URL, default is the default namespace, and $PartnerManagement is the endpoint suffix to retrieve the metadata.

    2. In the Namespace text box, enter a namespace, such as PartnerManagement.

    3. Select OK to add the reference to the Visual Studio project.

  4. In the .cs file, add a reference to the service namespace. For example, if the namespace for your C# project is BtsServices and the namespace for the service reference is PartnerManagement, add the following reference to your .cs file:

    using BtsServices.PartnerManagement;

    You can now start creating the entities, set their properties, and create relationships between the entities.


    Whenever you commit changes to the service context, you must always use the Batch save option. You can either set this option once when you create the context by using the following:

    context.SaveChangesDefaultOptions = SaveChangesOptions.Batch;

    Or, you can use it every time you save changes to a context.