Creating .NET Applications Using TPM OM REST API

 

Important

Microsoft Azure BizTalk Services (MABS) is being retired, and replaced with Azure Logic Apps. If you currently use MABS, then Move from BizTalk Services to Logic Appsprovides some guidance on moving your integration solutions to Logic Apps.

If you're brand new to Logic Apps, then we suggest getting started here:

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.

Typical Code Flow for using the API

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

Set up Your Computer

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 https://msdn.microsoft.com/library/dd831853.

  • Install WCF Data Services from https://www.microsoft.com/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.

The First Steps

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:

      https://mybiztalkservice.biztalk.windows.net/default/$PartnerManagement
      

      In this URL, https://mybiztalkservice.biztalk.windows.net 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.

    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.

    context.SaveChanges(SaveChangesOptions.Batch);

In This Section

See Also

Trading Partner Management Object Model (TPM OM): API Reference