With this library, you can make requests to SOAP server without using native PHP SOAP Client.
It uses PHP and cURL Library.
Create request file from SOAP Service WSDL (Can Use SoapUI) and save xml code to "requests" folder with method name: GetGeoIP(.xml).
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webservicex.net/">
<soap:Header/>
<soap:Body>
<web:GetGeoIP>
<!--Optional:-->
<web:IPAddress>{IPAddress}</web:IPAddress>
</web:GetGeoIP>
</soap:Body>
</soap:Envelope>
Define option parameters array:
$option = array(
//SOAP Server Address
'address' => 'http://www.webservicex.net/geoipservice.asmx',
//Folder where located Request files
'folder' => 'requests',
//Request data file extension
'ext' => 'xml',
);
Create Client Instance and make request:
$Client = CurlSOAPClient::getInstance($option);
//Define Service method parameters
$Params = array(
'IPAddress' => '72.52.91.14'
);
//Call Soap method 'GetGeoIP' with defined parameters
$Client->MakeRequest('GetGeoIP', $Params);
You can get result data with several methods:
$Client->GetXML();
Result:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetGeoIPResponse xmlns="http://www.webservicex.net/">
<GetGeoIPResult>
<ReturnCode>1</ReturnCode>
<IP>72.52.91.14</IP>
<ReturnCodeDetails>Success</ReturnCodeDetails>
<CountryName>United States</CountryName>
<CountryCode>USA</CountryCode>
</GetGeoIPResult>
</GetGeoIPResponse>
</soap:Body>
</soap:Envelope>
$Client->GetXML('GetGeoIPResult');
Result:
<GetGeoIPResult>
<ReturnCode>1</ReturnCode>
<IP>72.52.91.14</IP>
<ReturnCodeDetails>Success</ReturnCodeDetails>
<CountryName>United States</CountryName>
<CountryCode>USA</CountryCode>
</GetGeoIPResult>
$Client->GetArray('GetGeoIPResult');
Result:
Array
(
[ReturnCode] => 1
[IP] => 72.52.91.14
[ReturnCodeDetails] => Success
[CountryName] => United States
[CountryCode] => USA
)
$Client->GetObject('GetGeoIPResult');
Result:
stdClass Object
(
[ReturnCode] => 1
[IP] => 72.52.91.14
[ReturnCodeDetails] => Success
[CountryName] => United States
[CountryCode] => USA
)
$Client->GetTagValue('CountryName');
$Client->GetTagValue('CountryCode');
Result:
United States
USA