function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vijay NagarathinamVijay Nagarathinam 

Expose and consume in Webservice


I want to know, what is expose and consume in web service. If you know any real time scenarios please let me know.

NagendraNagendra (Salesforce Developers) 
Hi Vijay,

First, you need to understand what is a Web Service Class.

Web Service: Web services are Apex code that you expose out and can consume with either SOAP or REST.  Typically this is used to expose complex business logic in an easily consumable way.  For example, you could use a web service to combine together an account with all of it’s contacts and return them in a single call.

Expose in a web service: As your web service contains all the metadata which is needed to integrate with other application you need to expose the data of your org which is present in the web service.If the destination org is able to access all the metadata which is present in the source org then a successful integration would be possible.So the data which is present in source org has to be exposed in order to perform a valid integration.

Consume in a web service: The web service which is provided by the source org has to be accessed by the destination org in order to exchange the data.Accessing the source org metadata and reverting accordingly can be called as the process of consuming the web service.

Please let us know if you need any other information.

Hope this helps.

Mark this as solved if it's resolved.

Best Regards,