[SalesForce] Exposing same apex method via SOAP and REST API

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;
  }    

Best Answer

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');
    }

}
Related Topic