Calling a SOAP Web Service with PHP

I have never done this before, so I'm completely in the dark. I am using PHP and I need to call a SOAP service running on a remote server that answers the call with a status code. How exactly am I calling? The service runs on a specific ip / port and has a name, namely: http://1.2.3.4:1000/ServiceName?1234 , where 1234 is the parameter that I pass, and for which I expect a response from the service.

Please give me some recommendations, thanks!

+3
source share
3 answers

Assuming you have allow_url_fopenon (usually true), it might be as simple as ...

$response = file_get_contents('http://1.2.3.4:1000/ServiceName?1234');
+1
source

For very simple sets of request / response, you can basically do

 $response = file_get_contents('http://1.2.3.4:1000/ServiceName?1234');

- "", , , , cookie .., cURL, .

+1

If this is a SOAP / WSDL-based web service, you should study the SoapClient classes as they will basically do the majority for you.

Otherwise, you can use a basic call file_get_contentsto capture the web service response in a string.

This, obviously, will work only if you execute the request GET, for POSTand additional requirements see cURL .

0
source

All Articles