0

I need to send a SOAP request to Estes to retrieve rate quotes. I'm having trouble doing this as the other APIs I have worked with either post the XML or use a URL string. This is a bit different for me.

I believe my problem is that I cannot figure out the array that needs to be sent for the request.

<?xml version="1.0" encoding="UTF-8"?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http://ws.estesexpress.com/ratequote" xmlns:rat1="http://ws.estesexpress.com/schema/2012/12/ratequote">
           <soapenv:Header>
              <rat:auth>
                 <rat:user>XXXXX</rat:user>
                 <rat:password>XXXX</rat:password>
              </rat:auth>
           </soapenv:Header>
           <soapenv:Body>
              <rat1:rateRequest>
                 <rat1:requestID>XXXXXX</rat1:requestID>
                 <rat1:account>XXXXXXX</rat1:account>
                 <rat1:originPoint>
                    <rat1:countryCode>XX</rat1:countryCode>
                    <rat1:postalCode>XXXXX</rat1:postalCode>
                    <rat1:city>XXXXXX</rat1:city>
                    <rat1:stateProvince>XX</rat1:stateProvince>
                 </rat1:originPoint>
                 <rat1:destinationPoint>
                    <rat1:countryCode>XX</rat1:countryCode>
                    <rat1:postalCode>XXXXX</rat1:postalCode>
                 </rat1:destinationPoint>
                 <rat1:payor>X</rat1:payor>
                 <rat1:terms>XX</rat1:terms>
                 <rat1:stackable>X</rat1:stackable>
                 <rat1:baseCommodities>
                    <rat1:commodity>
                       <rat1:class>X</rat1:class>
                       <rat1:weight>XXX</rat1:weight>
                    </rat1:commodity>
                 </rat1:baseCommodities>
              </rat1:rateRequest>
           </soapenv:Body>
        </soapenv:Envelope>

This was the code I was using before and it is not working.

        <?php
    $client = new SoapClient("https://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl");

    $request_object = array(
          "header"=>array(
          "auth"=>array(
                "user"=>"XXXXX",
                "password"=>"XXXXX",
                )
          ),
          "rateRequest"=>array(
                "requestID"=>"XXXXXXXXXXXXXXX",
                "account"=>"XXXXXX",
          ),
            "originPoint"=>array(
                "countryCode"=>"XX",
                "postalCode"=>"XXXXX",
                "city"=>"XXXXX",
                "stateProvince"=>"XX",
          ),
            "destinationPoint"=>array(
                "countryCode"=>"XX",
                "postalCode"=>"XXXXX",
          ),
          "payor"=> "X",
          "terms"=> "XXXX",
          "stackable"=> "X",
            "baseCommodities"=>array(
                "commodity"=>array(
                    "class"=>"XX",
                    "weight"=>"XXXX",
                )
            ),
        );

        $result = $client->rateRequest(array("request"=>$request_object));

        var_dump($result);
    ?>

Here is the error

        Fatal error: Uncaught SoapFault exception: [Client] Function ("rateRequest") is not a valid method for this service in /home/content/54/11307354/html/test/new/estes.php:36 
        Stack trace: #0 /home/content/54/11307354/html/test/new/estes.php(36): SoapClient->__call('rateRequest', Array) #1 /home/content/54/11307354/html/test/new/estes.php(36): 
        SoapClient->rateRequest(Array) #2 {main} thrown in /home/content/54/11307354/html/test/new/estes.php on line 36
dbc
  • 104,963
  • 20
  • 228
  • 340
smack-a-bro
  • 691
  • 2
  • 13
  • 27
  • What error do you get? – silkfire Sep 12 '13 at 15:00
  • Thanks for your reply. I have added the error at the bottom of my original post. – smack-a-bro Sep 12 '13 at 15:06
  • You can see what functions are available by using the method ->__getFunctions(). Try that and see what you get. The method is probably called getQuote(). – silkfire Sep 12 '13 at 16:04
  • @smack-a-bro - if you figured out how to get it to work, can you assist at https://stackoverflow.com/questions/50912194/estes-rate-quote-php-soap-requst-returning-error – KDJ Jun 18 '18 at 14:58

4 Answers4

1

THis is how I build the commodities array from a class array & a weight

array:

// load the $params commodities array $comArray = array(); for ($i=0; $i<count($class_tbl); $i++) { $comArray[] = array('class'=>$class_tbl[$i], 'weight'=>$weight_tbl[$i]); }

The following code formats the accessorials array

if($inside == "Yes") {
      $accArray[$i] = "INS";   
        ++$i;
  }
    if($liftgate == "Yes") {
      $accArray[$i] = "LGATE";   
        ++$i;
  }
    if($call == "Yes") {
      $accArray[$i] = "NCM";   
        ++$i;
  }

The Estes destination accessorial code also should be added to the $accArray array if delivery is to other than a business (for instance school. church, etc.)

  • Larry, if you are still using SO, I could use some help getting Estes Rate Request to work, https://stackoverflow.com/questions/50912194/estes-rate-quote-php-soap-requst-returning-error – KDJ Jun 18 '18 at 14:56
1

This is my $params array that is passed to the Estes API

$params = array( 
    "requestID"         => "xxxxxxxx",
    "account"           => "xxxxxxxx",
    "originPoint"       => array('countryCode' => 'US', 'postalCode' => $fromzip),
    "destinationPoint"  => array('countryCode' => 'US', 'postalCode' => $shipzip),
    "payor"             => 'T',
    "terms"             => 'PPD',
    "stackable"         => 'N',
            "baseCommodities"   => array('commodity' => $comArray ),
            "accessorials"      => array('accessorialCode' => $accArray) 

If there are no accessorials, that array needs to be deleted from the $params array
); // remove accessorials entry if no accessorial codes if(sizeof($accArray) == 0){ $params = array_slice($params, 0, 8); // remove accesorials entry }

1

See if anything in our soap call helps. We are doing the soap call like this:

// define transaction arrays
$url = "http://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl";
$username = 'xxxxxxxx';
$password = 'xxxxxxxx';

// setting a connection timeout of five seconds
$client = new SoapClient($url, array("trace" => true,
         "exceptions" => true,
         "connection_timeout" => 5,
         "features" => SOAP_WAIT_ONE_WAY_CALLS,
         "cache_wsdl" => WSDL_CACHE_NONE));
    $old = ini_get('default_socket_timeout');
ini_set('default_socket_timeout', 5);

//Prepare SoapHeader parameters
$cred = array(
    'user'      => $username,
    'password'  => $password
);

$header = new SoapHeader('http://ws.estesexpress.com/ratequote', 'auth', $cred);
$client->__setSoapHeaders($header);

$params = array(
    "requestID"         => "xxxxxxxx",
    "account"           => "xxxxxxxx",
    "originPoint"       => array('countryCode' => 'US', 'postalCode' => $fromzip),
    "destinationPoint"  => array('countryCode' => 'US', 'postalCode' => $shipzip),
    "payor"             => 'T',
    "terms"             => 'PPD',
    "stackable"         => 'N',
            "baseCommodities"   => array('commodity' => $comArray ),
            "accessorials"      => array('accessorialCode' => $accArray)
);
    // remove accessorials entry if no accessorial codes
    if(count($accArray) == 0){
        $params = array_slice($params, 0, 8); // remove accesorials entry
    }

 // call Estes API and catch any errors
    try {
 $reply = $client->getQuote($params);
}
catch(SoapFault $e){
       // handle issues returned by the web service
       //echo "Estes soap fault<br>" . $e . "<br>";
       $edit_error_msg = "Estes quote API timed out or failed to return a quote";
         return "0.00";
}
catch(Exception $e){
       // handle PHP issues with the request
       //echo "PHP soap exception<br>" . $e . "<br>";
         $edit_error_msg = "Estes quote API timed out or failed to return a quote";
         return "0.00";
}
    unset($client);
  ini_set('default_socket_timeout', $old);

 // print_r($reply);
0

Looking up the WSDL with a validator it looks like the two methods available are echo and getQuote.

Looking at the WSDL itself you can see that too:

<wsdl:operation name="getQuote">
    <wsdl:input name="rateRequest" message="tns:rateRequestMsg"></wsdl:input>
    <wsdl:output name="quoteInfo" message="tns:rateQuoteMsg"></wsdl:output>
    <wsdl:fault name="schemaErrorMessage" message="tns:schemaErrorMsg"></wsdl:fault>
    <wsdl:fault name="generalErrorMessage" message="tns:generalErrorMsg"></wsdl:fault>
</wsdl:operation>

Try calling getQuote instead of rateRequest.

$result = $client->__soapCall('getQuote', array("request"=>$request_object));
quaspas
  • 1,351
  • 9
  • 17
  • Thanks. That seemed help help a bit but Im still getting an error. Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'requestID' property in /home/content/54/11307354/html/test/new/estes.php:36 Stack trace: #0 /home/content/54/11307354/html/test/new/estes.php(36): SoapClient->__soapCall('getQuote', Array) #1 {main} thrown in /home/content/54/11307354/html/test/new/estes.php on line 36 – smack-a-bro Sep 12 '13 at 16:08
  • [Try taking a look at the XML request you are sending, maybe add it to the question](http://php.net/manual/en/soapclient.getlastrequest.php). From that error I would assume that the array structure of your `request_object` is not being structured or wrapped in xml properly by the WSDL. Try trouble shooting with `__getLastRequest()`. – quaspas Sep 12 '13 at 16:13
  • Do I echo that or just straight "__getLastRequest()". – smack-a-bro Sep 12 '13 at 16:21
  • Take a look at the PHP docs for it. You need to set trace when you make the client too. http://www.php.net/manual/en/soapclient.getlastrequest.php – quaspas Sep 12 '13 at 16:27
  • @quaspas - If you are still using SO and can help, I'd love to help getting my estes rate request to work. https://stackoverflow.com/questions/50912194/estes-rate-quote-php-soap-requst-returning-error – KDJ Jun 18 '18 at 14:57