Creating .NET Applications Using TPM OM REST API
Updated: October 12, 2014
Because the TPM OM API is based on the OData protocol, you can use the WCF Data Services to create .NET applications that consume the data services exposed by the TPM OM. 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.
To start creating .NET applications for consuming data services exposed by TPM OM API, you need to install Visual Studio 2012 and WCF Data Services 5.0.
Install Visual Studio from http://msdn.microsoft.com/library/dd831853.
Install WCF Data Services from http://www.microsoft.com/en-us/download/details.aspx?id=29306.
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 provides the broad 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.
Create a Visual Studio C# project.
In the project Solution Explorer, right-click References, and then select Add Service Reference.
In the Add Service Reference dialog box, do the following:
For the address, enter the URL where the TPM OM service metadata is hosted and select Go. A typical URL for metadata looks like:
In this URL,
https://mybiztalkservice.biztalk.windows.netis your deployment URL,
defaultis the default namespace, and
$PartnerManagementis the endpoint suffix to retrieve the metadata.
In the Namespace text box, enter a namespace, such as PartnerManagement.
Select OK to add the reference to the Visual Studio project.
In the .cs file, add a reference to the service namespace. For example, if the namespace for your C# project is
BtsServicesand the namespace for the service reference is
PartnerManagement, add the following reference to your .cs file:
You can now start creating the entities, set their properties, and create relationships between the entities.
Important 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.