how to call salesforce Apex class from Java code.

I am trying to call salesforce metadata API to get info about particular object of salesfocce in Java.

closed as off-topic by David Reed, Jayant Das, battery.cord, glls, crmprogdev Sep 13 '18 at 13:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – David Reed, Jayant Das, battery.cord, glls, crmprogdev
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I have edited the tag here as this is not related to dx. Are you looking to invoke an apex class or metadata api from Java? I guess its the latter but your description says "call apex from java". If you need to see how to use metadata api in a client, start here. – Jayant Das Sep 12 '18 at 12:37
  • Have you looked at the Quick Start and Java examples in the Metadata API Developer Guide? – David Reed Sep 12 '18 at 12:40

If I read this right - you are looking to call metadata apis from your Java code. The best place is to start from the documentation for Metadata API Developer Guide. Refer to the Quick Start where you will find examples around invoking metadata apis from sample Java code.

In summary, this is what you will need:

  1. Get the WSDL from the Salesforce org
  2. Import the WSDL in your Java development environment
  3. Generate client out of the WSDL
  4. Invoke related API calls from your Java code

Again, your best place to go for more details is the official documentation.

On another note, if you are looking to "call Salesforce Apex class from Java code" - you cannot do that. You can only invoke Apex methods from any external client as long as they are exposed as a Webservice.

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