Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getDropOffPoints($zipCode, $city = null)
 {
     if (null === $city) {
         $city = $this->getCitiesGuide($zipCode)->getName();
     }
     try {
         $dropOffPoints = $this->client->dropOffPoints(array('zipCode' => $zipCode, 'city' => $city));
     } catch (\SoapFault $e) {
         $this->manager->handle($e);
     }
     if (!isset($dropOffPoints->DropOffPoint)) {
         throw new InvalidPairZipcodeCityException($zipCode, $city);
     }
     foreach ($dropOffPoints->DropOffPoint as $point) {
         $point->init();
     }
     return $dropOffPoints->DropOffPoint;
 }
Example #2
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;
    }