Glen Mazza's Weblog Sunday May 28, 2017

Using SoapUI to make Salesforce Marketing Cloud API calls

This tutorial shows how to make SOAP requests to Salesforce' Marketing Cloud API using the open source version of SmartBear's SoapUI. The feedback that SoapUI provides is very helpful in figuring out the correct SOAP request format for each action desired to run. SOAP request envelopes created within SoapUI can be easily saved for later reuse, allowing you to bypass the sometimes cumbersome Email Studio for often-run actions. Also, knowledge of the correct SOAP requests and SOAP responses returned helps speed up development for accessing the API via programmatic means, for example as shown in my Salesforce/Apache CXF tutorial. As with that tutorial, I'll be demonstrating creation of an email data folder, a simple task that provides an easy way to confirm connectivity and authentication before moving on to more complex activities.


  1. Download SoapUI if you haven't already. Free open source version will do.

  2. Import the Marketing Cloud WSDL into a new SoapUI project. Select SoapUI menu item File | New SOAP Project. A New SOAP Project popup will appear (see illustration below.) Choose whatever project name desired. For the Initial WSDL, that can be retrieved from the Salesforce Marketing Cloud (SFMC) WSDL Links page. Choose the WSDL appropriate for the SF instance that you are using: S1, S4, S6, or S7 -- the illustration below shows S1 which may or may not be the correct one for your project. Contact SF customer support if you are uncertain which SFMC instance you are using.


    Good to check "Create Requests" as shown above, although this functionality is less useful here than for other web services. SFMC uses generic SOAP operations like Create and Retrieve that hold for dozens of objects instead of specific ones such as CreateXXX, RetrieveYYY, etc. resulting in unworkably large sample SOAP requests to handle the many objects these methods can be applied to.

  3. Configure Username Token Authentication for the SOAP calls. This need be configured only once for all SOAP calls. SoapUI provides efficient documentation for configuring WS-Security, of which SFMC uses the UsernameToken type. To configure, select menu item Project | Show Project View and select the WS-Security Configurations tab from the resulting popup. The (anonymized) settings below are what I configured for my own calls to work, make sure you also have the configuration as given in the bottom half of the illustration. The "Name" field at the top of the illustration can be whatever you want, it is used to identify the security properties desired for any particular SOAP call. The username and password can be what you use to log into Email Studio or can be a new account used specifically for SOAP calls.

  4. Create the SOAP request envelope. General process:

    1. Clone the sample request provided by SoapUI. Creating a clone allows you customize the sample SOAP call to something specific for your needs, while allowing the sample SOAP call to remain as-is so you can clone it again to perform a different action. To clone, right-click the sample request, select "Clone Request" and give the clone a useful name (say "CreateDataFolder"). You'll see it created next to the original sample request. Double-click the cloned request to bring it up in the editor window.

    2. Configure the UsernameToken for the call. In the editor window for the CreateDataFolder call, select the Auth button in the lower-left corner, choose Basic Authentication, leave the basic auth username and password blank, and for Outgoing WSS select the name of the UsernameToken authentication you configured earlier (see illustration).

    3. Check the SFMC documentation to help determine the required SOAP request format for the desired action. For each action, some trial and error can be expected to figure out the correct call. SoapUI excels at providing pre-call validation and rapid SOAP responses helpful for getting the calls right. The best first step is to check the documentation page for the specific SFMC object you're working with, in this case it would be the Data Folder page (note the other objects listed on the left-side menu in case you're working with something else.) You'll get a reasonably accurate listing of properties that can be defined and the types of actions (Create, Retrieve, etc.) permissible on the object. In the case of the Data Folder and some other objects, the bottom of the page gives a link to sample SOAP requests which I've not found to provide everything that's needed but a good starting step. In the case of creating data folders, I've found the description field to be required (or an unclear error response is given), the xmlns:xsi namespace needed to be added to the soap:envelope and a Client element for your project's MemberID needed. You'll also need to determine the ID of the parent folder for the new folder you're creating, one way to obtain this is to hover over the parent directory with the mouse in Email Studio and reading the "cid" value given in the tooltip popup at the bottom of your browser while doing so. The following is the format that worked for me to create the data folder:

      <soapenv:Envelope xmlns:xsi="" xmlns:soapenv="" xmlns:par="">
                      <par:ModifiedDate xsi:nil="true"/>
                      <par:ObjectID xsi:nil="true"/>
                          <par:ModifiedDate xsi:nil="true"/>
                          <par:ObjectID xsi:nil="true"/>
    4. Validate the SOAP request prior to sending it. If the SOAP request is not valid (missing required elements for example), running it will return a "400 Bad Request" message in the response window. These types of errors can normally be trapped beforehand by right-clicking the SOAP request in the editor window and choosing "Validate". Soap UI will return any WSDL or XML Schema validation errors for you to fix.

  5. Make the SOAP call. Clicking the green arrow in the upper-left corner of the editor window is all that is needed. However, even with the validation done earlier, the SOAP response may return an error message indicating further tweaking needed.

    • Check the SOAP response for any useful information. In the case of a create data folder request, you'll receive the "NewID" of the folder you created, which you can use to make further changes to the folder. Below shows the (anonymized) SOAP response to my SOAP request:

      <soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="" xmlns:wsa="" xmlns:wsse="" xmlns:wsu="">
                  <wsu:Timestamp wsu:Id="Timestamp-zzzzzz">
              <CreateResponse xmlns="">
                      <StatusMessage>Folder created successfully.</StatusMessage>
    • Go into SFMC Email Studio to confirm the folder you created is there. If you had Email Studio already open, may need to refresh once or twice for the folder to appear. Can delete the folder from within the Studio if desired (or create another web service call to do that as well.)

    • Save the project to retain your SOAP request envelopes. Menu item Project | Save Project will do. Keeping this SOAP request template will allow you to tweak and reuse it later to create other folders.

Posted by Glen Mazza in Salesforce at 07:00AM May 28, 2017 | Comments[1]


This helped a lot. Thanks :)

Posted by Chans at 02:04AM Jan 16, 2018

Post a Comment:

« September 2021
Sun Mon Tue Wed Thu Fri Sat
About Me
Java Software Engineer
TightBlog project maintainer
Arlington, Virginia USA
glen.mazza at pm dot me
GitHub profile for Glen Mazza at Stack Overflow, Q&A for professional and enthusiast programmers
Blog Search

Blog article index
About Blog
Blog software: TightBlog 3.7.2
Application Server: Tomcat
Database: MySQL
Hosted on: Linode
SSL Certificate: Let's Encrypt
Installation Instructions