/** * Retrieves the calculated rate based on the shipment information. * * @return integer|float */ public function getResponse() { // initialize SOAP client $client = new SoapClient(self::RATE_WSDL); $funcs = $client->__getFunctions(); // initialize SOAP header $headerbody = array(self::USER_TOKEN => $this->_userToken); $header = new SoapHeader(self::HEADER, self::AUTH_HEADER, $headerbody); $client->__setSoapHeaders($header); // prepare parameters $query = array(self::SERVICE_TYPE => $this->_serviceType, self::SHIPMENT_TYPE => $this->_shipmentType, self::DESTINATION_VALUE => $this->_destinationValue, self::WEIGHT => $this->_weight, self::LENGTH => $this->_length, self::WIDTH => $this->_width, self::HEIGHT => $this->_height, self::VALUE => $this->_declaredValue, self::INSURANCE => true); // execute SOAP method try { $result = $client->Calculate($query); //catch soap fault } catch (SoapFault $soapfault) { $this->_exceptionFlag = true; $exception = $soapfault->getMessage(); preg_match_all('/: (.*?). at/s', $exception, $error, PREG_SET_ORDER); //Print error return $error[0][1]; } return $result->CalculateResult; }