Estes Rate Quote PHP SOAP Requst返回错误

时间:2018-06-18 14:51:07

标签: php soap soap-client

我一直试图让它工作一段时间。我希望熟悉它的人碰巧遇到问题,并且可以解释为什么这不起作用以及代码有什么问题。到目前为止,埃斯蒂斯在帮助方面毫无用处。他们为我提供了大量信息,但都没有。

以下代码返回此错误

  

致命错误:未捕获的SoapFault异常:[客户端] SOAP-ERROR:   编码:对象没有' requestID'物业   /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php:41堆栈追踪:#0   /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php(41):   SoapClient-> __ call(' getQuote',Array)#1 {main}抛出   第41行/home/xxxxxxxxxx/public_html/inc/estes/estesapi.php

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

我无法弄清楚为什么RequestID没有传递给soap请求。

1 个答案:

答案 0 :(得分:1)

这是我们的Estes Soap电话。看看是否有任何帮助的东西:

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