Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a SOAP web service from PHP

Tags:

php

soap

service

I've never done this before so I'm completely in the dark. I'm using PHP and I need to call a SOAP service running on a remote server that responds to a call with a status code. How exactly do I make a call? The service is running on a specific ip/port and it has a name, ie: http://1.2.3.4:1000/ServiceName?1234 where 1234 is a parameter I'm passing and for which I expect an answer from the service.

Please give me a few guidelines, thanks!

like image 832
bikey77 Avatar asked Jan 28 '26 00:01

bikey77


2 Answers

Assuming you have allow_url_fopen on (usually true), it may be as simple as...

$response = file_get_contents('http://1.2.3.4:1000/ServiceName?1234');
like image 173
ceejayoz Avatar answered Jan 30 '26 15:01

ceejayoz


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

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

If you need to do anything "special", like authenticate to the server, log in, process cookies, etc... you'd be better off using cURL instead, or look at the streams wrapper stuff.

like image 22
Marc B Avatar answered Jan 30 '26 16:01

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!