<?php
define(‘AUTH_ID’, ‘INSERT BROKER ID’);
define(‘AUTH_API_KEY’, ‘INSERT BROKER API KEY’);
echo ‘<pre>’;
try
{
$wsdl = ‘https://carrentalsoftware.myappy.it/web/ota/wsdl/opentravel.wsdl’;
// $wsdl = __DIR__ . ‘/wsdl/opentravel.wsdl’;
$client = new SoapClient($wsdl, array(‘trace’ => 1, ‘cache_wsdl’ => WSDL_CACHE_NONE));
$functions = $client->__getFunctions ();
print_r($functions);
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
echo “\n” . ‘OTA_PingRQ’ . “\n\n”;
$xml = ‘
<ns1:OTA_PingRQ><EchoData>This is the cool string</EchoData></ns1:OTA_PingRQ>’;
$res = $client->OTA_Ping(new SoapVar($xml, XSD_ANYXML));
if ($res->Success)
{
}
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastRequest());
echo htmlspecialchars($dom->saveXML());
echo “\n\n”;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastResponse());
echo htmlspecialchars($dom->saveXML());
echo “\n\nOTA_VehLocSearch\n\n”;
$xml = ‘
<ns1:OTA_VehLocSearchRQ>
<POS>
<Source>
<RequestorID Type=”29″ ID=”‘ . AUTH_ID . ‘” MessagePassword=”‘ . AUTH_API_KEY . ‘”><CompanyName>Comp</CompanyName></RequestorID>
</Source>
</POS>
<VehLocSearchCriterion>
<Address>
<CityName>APT</CityName>
</Address>
</VehLocSearchCriterion>
<VehLocSearchCriterion>
<Telephone PhoneNumber=”334453″/>
</VehLocSearchCriterion>
</ns1:OTA_VehLocSearchRQ>’;
$res = $client->OTA_VehLocSearch(new SoapVar($xml, XSD_ANYXML));
$base = NULL;
if ($res->Success)
{
if (@count($res->VehMatchedLocs->VehMatchedLoc) > 1)
{
$base = $res->VehMatchedLocs->VehMatchedLoc[0];
}
else
{
$base = $res->VehMatchedLocs->VehMatchedLoc;
}
}
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastRequest());
echo htmlspecialchars($dom->saveXML());
echo ‘<br /><br />’;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastResponse());
echo htmlspecialchars($dom->saveXML());
echo “\n\nOTA_VehAvailRate\n\n”;
$xml = ‘
<ns1:OTA_VehAvailRateRQ>
<POS>
<Source>
<RequestorID Type=”29″ ID=”‘ . AUTH_ID . ‘” MessagePassword=”‘ . AUTH_API_KEY . ‘”><CompanyName>Comp</CompanyName></RequestorID>
</Source>
</POS>
<VehAvailRQCore>
<VehRentalCore PickUpDateTime=”2019-12-30T10:56:00″ ReturnDateTime=”2020-01-04T10:56:00″>
<PickUpLocation LocationCode=”‘ . $base->LocationDetail->Code . ‘”/>
<ReturnLocation LocationCode=”‘ . $base->LocationDetail->Code . ‘”/>
</VehRentalCore>
</VehAvailRQCore>
</ns1:OTA_VehAvailRateRQ>’;
$res = $client->OTA_VehAvailRate(new SoapVar($xml, XSD_ANYXML));
if ($res->Success)
{
}
else if ($res->Errors)
{
foreach ($res->Errors as $e)
{
echo print_r($e, TRUE);
}
}
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastRequest());
echo htmlspecialchars($dom->saveXML());
echo ‘<br /><br />’;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastResponse());
echo htmlspecialchars($dom->saveXML());
}
catch (\Exception $e)
{
echo ‘SOAP EXCEPTION<br />’;
var_dump($e);
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastRequest());
echo htmlspecialchars($dom->saveXML());
echo ‘<br /><br />’;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($client->__getLastResponse());
echo htmlspecialchars($dom->saveXML());
echo $client->__getLastResponse();
}
echo ‘</pre>’;
?>