Example #1
0
function suivi_colis($suivi)
{
    $url = 'http://www.tnt.fr/service/tracking?wsdl';
    $username = '';
    $password = '';
    $authheader = sprintf('
						<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
						  <wsse:UsernameToken>
							<wsse:Username>%s</wsse:Username>
							<wsse:Password>%s</wsse:Password>
						 </wsse:UsernameToken>
						</wsse:Security>', htmlspecialchars($username), htmlspecialchars($password));
    $authvars = new SoapVar($authheader, XSD_ANYXML);
    $header = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authvars);
    $soap = new SoapClient($url, array('trace' => 1));
    $soap->__setSOAPHeaders(array($header));
    try {
        $result = $soap->trackingByConsignment(array('parcelNumber' => $suivi));
        $etape = getStage($result);
        if (is_array($result->Parcel->longStatus)) {
            $statut = $result->Parcel->longStatus[0];
            $message = $result->Parcel->longStatus[1];
        } else {
            $statut = $result->Parcel->longStatus;
            $message = '';
        }
        $result = 'tntB2CSuiviColisDisplayDetail(["' . $result->Parcel->consignmentNumber . '","' . $result->Parcel->reference . '","' . $result->Parcel->receiver->city . '","","",["' . $statut . '","' . $message . '"],[],"' . $etape . '"])';
    } catch (Exception $e) {
        $result = $e->getMessage();
    }
    return $result;
}
Example #2
0
 /**
  * Return a new instance of SoapClient
  *
  * @param bool $sandBox
  *
  * @return \SoapClient
  */
 public function createClient($sandBox = false)
 {
     $client = new \SoapClient($this->wsdl, array('soap_version' => SOAP_1_1, 'classmap' => $this->classmap));
     $login = $sandBox ? self::TEST_LOGIN : $this->login;
     $password = $sandBox ? self::TEST_PASSWORD : $this->password;
     $client->__setSOAPHeaders($this->getSecurityHeader($login, $password));
     return $client;
 }
Example #3
0
function getDepot($soapclient, $code)
{
    $services = $soapclient->tntDepots(array('department' => $code));
    return $services;
}
if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) {
    echo '<span style="color:red">No account found</span>';
} else {
    $code = $_GET['code'];
    $authheader = genAuth(Configuration::get('TNT_CARRIER_LOGIN'), Configuration::get('TNT_CARRIER_PASSWORD'));
    $authvars = new SoapVar($authheader, XSD_ANYXML);
    $header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvars);
    $file = "http://www.tnt.fr/service/?wsdl";
    try {
        $soapclient = new SoapClient($file, array('trace' => 1));
        $soapclient->__setSOAPHeaders(array($header));
        $follow = getDepot($soapclient, $code);
    } catch (SoapFault $e) {
        $erreur = $e->faultstring;
        echo $erreur;
    } catch (Exception $e) {
        $erreur = "Problem : follow failed";
    }
    if (isset($follow)) {
        if (isset($follow->DepotInfo)) {
            $v = $follow->DepotInfo;
            if (!is_array($follow->DepotInfo)) {
                echo "\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCode' value='{$v->pexCode}'/>\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedNom' value='{$v->name}'/>\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedAdresse' value='{$v->address1}'/>\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedAdresse2' value='{$v->address2}'/>\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCodePostal' value='{$v->zipCode}'/>\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCommune' value='{$v->city}'/>";
            } else {
                echo "\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCode' />\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedNom' />\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedAdresse' />\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedAdresse2' />\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCodePostal' />\r\n\t\t\t\t\t<input type='hidden' id='tntRCSelectedCommune' />";
            }
Example #4
0
    protected function ws_tnt_communication($fonction, $parametres)
    {
        $url = $this->getConfigData('gateway_url');
        $username = $this->getConfigData('identifiant');
        $password = $this->getConfigData('mdp');
        $authheader = sprintf('
			<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
			  <wsse:UsernameToken>
				<wsse:Username>%s</wsse:Username>
				<wsse:Password>%s</wsse:Password>
			 </wsse:UsernameToken>
			</wsse:Security>', htmlspecialchars($username), htmlspecialchars($password));
        $authvars = new SoapVar($authheader, XSD_ANYXML);
        $header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvars);
        //$soap = new SoapClient($url, array('trace'=>1));
        $soap = new SoapClient($url, array('trace' => 1, 'stream_context' => stream_context_create(array('http' => array('user_agent' => 'PHP/SOAP', 'accept' => 'application/xml')))));
        $soap->__setSOAPHeaders(array($header));
        try {
            if ($fonction == 'feasibility') {
                $result = $soap->feasibility(array('parameters' => $parametres));
            }
            if ($fonction == 'dropOffPoints') {
                $result = $soap->dropOffPoints($parametres);
            }
            if ($fonction == 'citiesGuide') {
                $result = $soap->citiesGuide($parametres);
            }
            if ($fonction == 'expeditionCreation') {
                $result = $soap->expeditionCreation($parametres);
            }
        } catch (Exception $e) {
            $result = $e->getMessage();
        }
        return $result;
    }