/** * {@inheritdoc} */ public function createExpedition(ExpeditionRequest $expeditionRequest) { $this->ensureParameters($expeditionRequest, array('shippingDate', 'accountNumber', 'sender', 'receiver', 'serviceCode', 'quantity', 'parcelsRequest', 'labelFormat')); try { $result = $this->client->expeditionCreation(array('parameters' => $expeditionRequest->toArray())); } catch (\SoapFault $e) { $this->manager->handle($e); } if (!isset($result->Expedition)) { throw new ClientException('No Expedition in results.'); } $expedition = $result->Expedition; $expedition->init(); return $expedition; }
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; }