4

Is it possible to expose a single method in salesforce and make it available via soap and rest? I am looking at the docs and seems like you can't. For example on this page: https://developer.salesforce.com/page/Creating_REST_APIs_using_Apex_REST

would i be able to do this? I am currently testing this out in dev org but wanted to see if anyone knew right away

@HttpGet
  webService static List<Case> getOpenCases() {
    // some logic
    return cases;
  }    
5

Looks like you can expose the same apex method both via SOAP and REST API..I tried the below code and executed via SOAPUI(for SOAP protocol) and workbench(REST protocol) and it worked fine and the bebug statement printed in logs.

@RestResource(urlmapping = '/someUrl/*')
global class SOAPRESTClass {

    @HttpGet
    webservice static void someMethod(){
        System.debug('From someMethod');
    }

}
  • Granted, that might have some unintended side effects, like if you need to accept some types of parameters. Overall, though, I love the efficiency of the design. – sfdcfox Sep 7 '15 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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