It depends on what information your external service is providing, but often webservices provide additional information in the headers. You can try to call the webservice using Postman and investigating the response headers to see if they return any information. Alternatively, check with your external service provider if they can supply this information with the request.
An example of a webservice I'm using:
With some custom Java you would be able to get as much as the mime type (https://stackoverflow.com/questions/51438/how-to-get-a-files-media-type-mime-type#847849), which would still not give you the file extension.
If you could receive the file name from the external resource then you could use a RegEx to extract the file extension from the name...