<?php

$soapRequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Inquiry_OrfOstanPrice>
         <tem:UserID>test</tem:UserID>
         <tem:Password>123456</tem:Password>
         <tem:OriginCode>1</tem:OriginCode>
         <tem:DestCode>2</tem:DestCode>
         <tem:BargirCode>5</tem:BargirCode>
         <tem:KalaCode>1</tem:KalaCode>
         <tem:Weight>300</tem:Weight>
         <tem:CompanyCommission>50</tem:CompanyCommission>
         <tem:IsTrafficLoad>false</tem:IsTrafficLoad>
      </tem:Inquiry_OrfOstanPrice>
   </soapenv:Body>
</soapenv:Envelope>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://bar-test.rmto.ir/TRNServiceV03.svc');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soapRequest);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: text/xml; charset=utf-8',
    'SOAPAction: "http://tempuri.org/TRNServiceV03/Inquiry_OrfOstanPrice"'
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$effectiveUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$error = curl_error($ch);
curl_close($ch);

echo "HTTP Code: $httpCode\n";
echo "Effective URL: $effectiveUrl\n";
if ($error) {
    echo "CURL Error: $error\n";
} else {
    echo "Response length: " . strlen($response) . "\n";
    echo "Response:\n" . substr($response, 0, 1000) . "\n";
}