【问题标题】:Estes Rate Quote PHP SOAP Requst returning errorEstes Rate Quote PHP SOAP请求返回错误
【发布时间】:2018-06-18 14:51:06
【问题描述】:

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

下面的代码返回这个错误

致命错误:未捕获的 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} 抛出 /home/xxxxxxxxxx/public_html/inc/estes/estesapi.php 在第 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);

我不明白为什么 RequestID 没有被传递到soap请求中。

【问题讨论】:

  • 为什么要将所有数据传递给`header'属性?
  • 标题在第 9 行结束
  • 是的,你说得对。我使用 SOAP 的经验是文档有时与 WSDL 文件不匹配。所以阅读 WSDL 文件并检查所需的参数
  • 我希望有更多的文档。文档不是很好,没有详细说明,公司“不知道 php”,无法提供任何进一步的帮助。 ://

标签: php soap soap-client


【解决方案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);

【讨论】:

  • 您可能没有设置 Estes Bill of Lading api 对吧?
  • 不,我们的托运人会这样做。
  • estes 跟踪怎么样?你可能有代码吗?我尝试修改它,但没有得到回复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-29
  • 2019-11-12
相关资源
最近更新 更多