Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to connect to an external application for which I'm provided with "usernames, passwords, token id, host url". This host url is a WSDL one which ends with "..sample.php?wsdl" and upon running it in the browser, it lists out the methods it has got. Till these days, I was using RESTful services to connect to that application.

Now, I would like to know how to invoke those "methods" from WSDL link and get the needed response from them.

share|improve this question

As in other programming languages, you can generate Apex code starting from the WSDL using the "Generate from WSDL" button present at the top of the Apex Classes list in the Setup UI. The process is described e.g. in SOAP Services: Defining a Class from a WSDL Document.

However, there are a number of limitations in that tooling, including that it only supports SOAP 1.1. Some of these can be worked around by editing a copy of the WSDL before the Apex code is generated (very commonly needed) and others by editing the generated Apex code. Googling will return a number of postings on that subject e.g. Getting Apex2wsdl parse External application WSDLs and make it work.

The most extreme work-around is to manually write Apex code that generates the request XML, makes the HTTP calls and parses the response XML: the WSDL contains all the necessary specification to be able to do that (but WSDL and the XML Schema that is part of it are not simple things). That is a lot of work and not easy to get right.

So the overall approach is to get the WSDL file, and start by using "Generate from WSDL" and deal with the problems that come up. You could be lucky and experience few or no problems...

(You will have to wire up e.g. a button to a controller to test calls against the real external service as such calls can't be made from an Apex unit test: only calls to a mock can be made from unit tests.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.