Connecting to the SOAP API using WCF

This page contains information on connecting your development environment or other systems to the Marketing Cloud SOAP API using the WCF standards.

This information contains instructions for connecting using Visual Studio 2008 and Visual Studio Express 2008. For Visual Studio 2005 andVisual Studio Express 2005, connect using WCE 3.0.

Why Connect to the SOAP API using WCF

You can use the connection to the SOAP API to test your calls and perform various tasks, such as sending email and retrieving tracking information.

How To Connect to the SOAP API using WCF and the Web.config File

Follow these steps to create a new VS2010 or VS2008 ASP.NET web application project:

  1. Create a new project using the ASP.NET Web Application template.
  2. Click OK.
  3. In your new project, add a service reference by right-clicking the References entry and selecting Add Service Reference.
    ServiceReference.jpg
    If you work within Visual Studio 2010 and don't see the Add Service Reference option, change the target framework of your project from .NET Framework 4 Client Profile to .NET Framework 4.
  4. In the Add Service Reference window, enter the appropriate WSDL URL (depending on what instance your account uses)in the Address field and enter your chosen value for the namespace. You can make the latter value whatever you want, but you must use that value consistently in your code.
    AddServiceReference.jpg
  5. Click OK.
  6. In the web.config file, create a "customBinding" node within the bindings section.
  7. Modify the "endpoint" node within the client section changing the binding attribute from "basicHttpBinding" to "customBinding". If you used a Namespace value other than "ExactTargetClient", you need to modify the "contract" attribute by replacing "ExactTargetClient" with the Namespace value you used.

Web.config Sample Code

How To Connect to the SOAP API using WCF and C# Code

Follow these steps to create a new VS2010 or VS2008 ASP.NET web application project:

  1. Create a new project using the ASP.NET Web Application template.

  2. Click OK.

  3. In your new project, add a service reference by right-clicking the References entry and selecting Add Service Reference.

    If you work within Visual Studio 2010 and don't see the Add Service Reference option, change the target framework of your project from .NET Framework 4 Client Profile to .NET Framework 4.

  4. In the Add Service Reference window, enter https://YOUR_SUBDOMAIN.soap.marketingcloudapis.com/etframework.wsdl (or the correct URL for your instance after consulting with your Marketing Cloud relationship manager) in the Address field and enter your chosen value for the namespace. You can make the latter value whatever you want, but you must use that value consistently in your code.

  5. Click OK.

  6. Use the sample code to create the binding in your calls.

Sample Code

The sample code below demonstrates how to connect and interact with the SOAP API.

Create a New Subscriber

Create a New Email Message

You can also download sample code to run a simple retrieve call that demonstrates you have correctly connected to the SOAP API using the WCF security specification.