Connecting to SOAP API using WCF

Use sample code and language details here to connect your development environment to Marketing Cloud Engagement using SOAP API.

These connection instructions use Visual Studio 2008 and Visual Studio Express 2008.

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

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.

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) 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.

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

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.