web service

hello, I need to develop a plugin that is a web service. They told me to follow the guidance of elgg related to web services. I need to create a web service that is called from another web service that passes some data in json format and other parameters as and after must send the same to another web service in the same way .. well a web service that acts as an intermediary between 2 web services. How will the structure of the plugin? start.php what I put in? how to write the function that will be exposed then? Thanks