Assuming that my site uses a database through the web service to fetch content, style and other things for my site. Can we make this connection in a way provided by the CMS? A plugin does that? Should we do it ourselves?
Thanks for answers.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
Yes, you can write php code, potentially in the form of a plugin, to access a remote web service.
Presumably you want to use a web service accessed via https (or http). WordPress provides the wp_remote_request() function to do that. You can call it from your php code (in your plugin). When your server runs that function, it will retrieve a result from your web service. You can then use it as needed. Notice this is server-side code, not client-side.
Edit You can write a plugin, but that takes software-engineering work to make it integrate cleanly with your site.
You can use the Code Snippets plugin to insert a little chunk of php. That's ok for development and experimentation, but a sizable security risk in production (or in dev for that matter).
Some suggest editing your theme's functions.php file to add a bit of code. But I don't suggest that approach: theme updates will make your changes vanish.
You didn't mention what you want to do with the result you get back from your webservice, so it's hard to recommend which hook you should use to invoke your code.
The answer to the current question is found. Thank you all for your answers.
The answer to the question is 'yes'. We can use an external webservice/API in the Wordpress code. We can use for this, wp_remote_request to call through an URL. For my part, I did otherwise because my webservice is a special one, so I created a SoapClient class in the files of my plugin to make the connection and the function calls.
To provide a correct display of the webservice, I decided to use 2 widgets. 1 for the search and 1 for the display. I still have some problems with the display with the web page but that will be another issue. Thanks again.