[SalesForce] Calling runApex or executeanonymous from SOAP

Is there a way to call sforce.interaction.runApex or executeanonymous from the SOAP enterprise API?

I have a manged package that has an APEX method on it that I need to run from Java. The SOAP proxy doesn't seem to have an equivalent of either of these functions.

Best Answer

While the Enterprise WSDL doesn't expose it there are two other SOAP based APIs that will directly allow you to invoke executeanonymous from an external system.

The preferred and current method is via the Tooling API executeanonymous(string apexcode) method. There are both SOAP and REST based versions of this API.

The older version is in the Apex API executeanonymous().

Both the Tooling and the Apex SOAP API WSDLs are independent of the Enterprise WSDL and will need to be downloaded separately.

I've got an example of the raw SOAP request to execute anonymous in Adding Eval() support to Apex


The alternative, as Toby answered, is to create the web service direction in Apex and then export the WSDL from that class in the org with the managed package installed.

Related Topic