[SalesForce] Call REST Webservice in Salesforce from external system

I'm writing a webservice from Salesforce that I can call from an external system, but for my life I cannot remember/find how to successfully call it. I am using a website in order to test the dummy service I created: http://resttesttest.com/

Code:

@RestResource
global with sharing class MyServices
{
    global static String createCase(String pCode, String rType, String subject, String description, String lookupInfo, String aaNum)
    {
      return 'success';
    }
}

What is the minimum info I must put into my call to make this work, or am I going about this completely wrong?

EDIT: I added @RestResource and set up a connected App in my Salesforce org now.

Best Answer

By using the webservice key word you are creating something that is to be exposed through SOAP. You can select the class and use the "Generate WSDL" button to generate the WSDL that external tooling can consume.

If you want to avoid SOAP and WSDL, then make use of the @RestResource annotation instead. This also allows the content to be in JSON format which is generally easy for clients (including JavaScript apps running in the browser) to create and consume.

Note that in both cases the request will have to include some authentication information (see e.g. OAUTH). (But also see BritishBoyinDC's comment.)

Related Topic