Estes Rate Quote PHP SOAP Requst returning error

醉酒当歌 提交于 2019-12-02 18:24:24

问题


I have been attempting to get this to work for a while. I am hoping someone familiar with it happens to run across the question and can explain WHY this isnt working and what is wrong with the code. Estes has been useless in helping thus far. They have provided me a bunch of information but none of it works.

The code below is returning this error

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'requestID' property in /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php:41 Stack trace: #0 /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php(41): SoapClient->__call('getQuote', Array) #1 {main} thrown in /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php on line 41

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

    $request_object = array(
     "header"=>array(
          "auth"=>array(
                "user"=>"xxxxxxxxx",
                "password"=>"xxxx",
                )
          ),

          "rateRequest"=>array(
                "requestID"=>"abc",
                "account"=>"############",

            "originPoint"=>array(
                "countryCode"=>"US",
                "postalCode"=>"28366",
                "city"=>"Newton Grove",
                "stateProvince"=>"NC",
          ),
            "destinationPoint"=>array(
                "countryCode"=>"US",
                "postalCode"=>"28334",
          ),
          "payor"=> "S",
          "terms"=> "P",
          "stackable"=> "N",
            "baseCommodities"=>array(
                "commodity"=>array(
                    "class"=>"50",
                    "weight"=>"1200",
                )
            )
 )

        );

        $result = $client->getQuote($request_object);

        var_dump($result);

print_r($result);

I cant figure out why RequestID isnt being passed into the soap request.


回答1:


This is our Estes Soap call. See if you see anything in it that helps:

// 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);


来源:https://stackoverflow.com/questions/50912194/estes-rate-quote-php-soap-requst-returning-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!