Execute anonymous Apex SOAP request

Posted on 31-01-2013 11:51 by graham
This tutorial shows how to execute anonymous Apex code using Salesforce Apex API. It shows how to build a SOAP request that you can later send to Salesforce using some SOAP tool, e.g. SoapUI.

If you are looking for a way to execute Apex from a higher-level library, e.g. from Java, see our tutorial about executing anonymous Apex using SOAP API.

Building a SOAP request

To send a SOAP request to Apex API and execute some Apex code, you need to build your request like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:apex=”http://soap.sforce.com/2006/08/apex">

The DebuggingHeader is optional. The reason we add it is because we want to obtain debug logs for our call in the Web Service call response.


Add comment

Has this tutorial been helpful to you? Or do you see anything wrong? We appreciate your opinion!
Your comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems