Friday, April 10, 2015

Salesforce Partner/Enterprise SOAP API QuickStart - Part 1: Setting Up Your WSDL

Using the Salesforce SOAP API in .NET is not straight forward there are a few quirks from the normal way you use SOAP.  You can either follow your way through some of my gotchas or you can bypass all that and use the Salesforce SOAP API QuickStart Module available by emailing me at

To obtain the enterprise SOAP API WSDL you need to log into as the administrator.  Once you have done that you can scroll down and on the left hand side you will see the developer menu.  Click on it.

If it scrolled you to the top scroll down and note that the develop menu is now opened. Click on the API option.
There are a few APIs listed.  The Enterprise API is specific to your organization.  It can save you some time as it will know some things about your environment but most likely you want the Partner API as you can then share your code or modules with others who work for different organizations.  I will generate using the Partner API but the generation will be similar for Enterprise.

Once it generates you will see the an xml and get excited and rush off to take the Url and use it in Visual Studio as the WSDL.  Don't Rush off so soon as it will not work. You will get this error:

There was an error downloading '$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: ''.
The content type text/html;charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 597 bytes of the response were: '
The reason being that the WSDL is secured.  You can see it in the browser because you are logged into however Visual Studio is NOT logged in.  To get around this.  Right Click on the page and click Save As

Save the WSDL on the file system in a place your Visual Studio Project can access it. Now in your Visual Studio Project choose Add Service Reference

Now in the reference box put the path to the xml file you saved for the WSDL then click Go.  Once You will see in the services box that the api has loaded

NOTE: If you are using .NET 2.0 then you may get an error in the WSDL related to the date fields. Thanks Alex for the information below:

There is a parsing issue when using .NET 2.0 with date time fields in salesforce, accessing through web services.
It seems to be a bug in .NET but there's another way to address it by manually editing the wsdl.
More information here:
 Enter a namespace for your service and click OK

The next step is to download the Force.Com Cookbook. This will provide you with what you need to get started such as login/logout and searching.

If you have questions or would like a copy of the Salesforce SOAP API QuickStart Module email me at This module is free to use the only thing I as is if you add new functionality to it or fix any issues in it that you send me the changes so I can share them with others using the module.

No comments:

Post a Comment