Can we use a webservice with WordPress?

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.

Or you can use the simpler wp_remote_post() or wp_remote_get() functions if they work for your web service.

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.