du94414
2018-06-18 14:51
浏览 40
已采纳

Estes Rate引用PHP SOAP请求返回错误

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条回答 默认 最新

  • douyun3022 2018-06-19 17:16
    已采纳

    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);
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题