Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 需要向Estes发送SOAP请求的帮助吗_Php_Xml_Soap - Fatal编程技术网

Php 需要向Estes发送SOAP请求的帮助吗

Php 需要向Estes发送SOAP请求的帮助吗,php,xml,soap,Php,Xml,Soap,我需要向Estes发送一个SOAP请求以检索费率报价。我很难做到这一点,因为我使用的其他API要么发布XML,要么使用URL字符串。这对我来说有点不同 我相信我的问题是,我无法找出需要为请求发送的数组 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http:/

我需要向Estes发送一个SOAP请求以检索费率报价。我很难做到这一点,因为我使用的其他API要么发布XML,要么使用URL字符串。这对我来说有点不同

我相信我的问题是,我无法找出需要为请求发送的数组

<?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>
看起来有两种可用的方法是
echo
getQuote

查看WSDL本身,您也可以看到:

<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>
看起来有两种可用的方法是
echo
getQuote

查看WSDL本身,您也可以看到:

<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>

这就是我如何从类数组&权重构建商品数组的方法

array:
//加载$params商品数组
$comArray=array();
对于($i=0;$i$class_-tbl[$i],'weight'=>$weight_-tbl[$i]);
}

下面的代码格式化了附件数组

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

如果交付对象不是企业(例如school.church等),则Estes目的地附加代码也应添加到$accArray数组中。

这就是我如何从类数组和权重构建商品数组的方法

array:
//加载$params商品数组
$comArray=array();
对于($i=0;$i$class_-tbl[$i],'weight'=>$weight_-tbl[$i]);
}

下面的代码格式化了附件数组

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

如果交付对象不是企业(例如school.church等),则还应将Estes目的地附加代码添加到$accArray数组中。

这是传递给Estes API的我的$params数组

$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) 
如果没有附件,则需要从$params数组中删除该数组
); //如果没有附加代码,请删除附加条目 if(sizeof($accArray)==0){ $params=array_slice($params,0,8);//删除附件条目
}

这是传递给Estes API的$params数组

$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) 
如果没有附件,则需要从$params数组中删除该数组
); //如果没有附加代码,请删除附加条目 if(sizeof($accArray)==0){ $params=array_slice($params,0,8);//删除附件条目
}

看看我们的soap调用是否有帮助。我们正在这样做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);
//定义事务数组
$url=”http://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl";
$username='xxxxxxxx';
$password='xxxxxxxx';
//将连接超时设置为5秒
$client=new SoapClient($url,数组(“跟踪”=>true,
“例外”=>正确,
“连接超时”=>5,
“功能”=>SOAP\u WAIT\u单向调用,
“cache_wsdl”=>wsdl_cache_NONE));
$old=ini_get('default_socket_timeout');
ini设置(“默认套接字超时”,5);
//准备SoapHeader参数
$cred=数组(
“用户”=>$username,
“密码”=>$password
);
$header=新的SoapHeader('http://ws.estesexpress.com/ratequote","auth","cred",;
$client->uu setSoapHeaders($header);
$params=数组(
“请求ID”=>“xxxxxxxx”,
“账户”=>“xxxxxxxx”,
“originPoint”=>数组('countryCode'=>'US','postalCode'=>$fromzip),
“destinationPoint”=>数组('countryCode'=>'US','postalCode'=>$shipzip),
“付款人”=>“T”,
“术语”=>“PPD”,
“可堆叠”=>“N”,
“基本商品”=>array('commodity'=>$comArray),
“附件”=>array('accessorialCode'=>$accArray)
);
//如果没有附加代码,请删除附加条目
if(计数($accArray)==0){
$params=array_slice($params,0,8);//删除附件条目
}
//调用ESTESAPI并捕获任何错误
试一试{
$reply=$client->getQuote($params);
}
捕获(SoapFault$e){
//处理web服务返回的问题
//echo“Estes soap错误
”$e.
”; $edit\u error\u msg=“Estes报价API超时或未能返回报价”; 返回“0.00”; } 捕获(例外$e){ //处理请求中的PHP问题 //echo“PHP soap异常
”$e.
”; $edit\u error\u msg=“Estes报价API超时或未能返回报价”; 返回“0.00”; } 未结算($客户); ini_集('default_socket_timeout',$old); //打印(回复);
看看我们的soap调用是否有帮助。我们正在这样做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);
//定义事务数组
$url=”http://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl";
$username='xxxxxxxx';
$password='xxxxxxxx';
//将连接超时设置为5秒
$client=new SoapClient($url,数组(“跟踪”=>true,
“例外”=>正确,
“连接超时”=>5,
“功能”=>SOAP\u WAIT\u单向调用,
“cache_wsdl”=>wsdl_cache_NONE));
$old=ini_get('default_socket_timeout');
ini设置(“默认套接字超时”,5);
//准备SoapHeader参数
$cred=数组(
“用户”=>$username,
“密码”=>$password
);
$header=新的SoapHeader('http://ws.estesexpress.com/ratequote","auth","cred",;
$client->uu setSoapHeaders($header);
$params=数组(
“请求ID”=>“xxxxxxxx”,
“账户”=>“xxxxxxxx”,
“originPoint”=>数组('countryCode'=>'US','postalCode'=>$fromzip),
“destinationPoint”=>数组('countryCode'=>'US','postalCode'=>$shipzip),
“付款人”=>“T”,
“术语”=>“PPD”,
“可堆叠”=>“N”,
“基本商品”=>array('commodity'=>$comArray),
“附件”=>array('accessorialCode'=>$accArray)
);
//如果没有附加代码,请删除附加条目
if(计数($accArray)==0){
$params=array_slice($params,0,8);//删除附件条目
}
//调用ESTESAPI并捕获任何错误