/** * Creates a SOAP client and initializes the headers etc * * @return \SoapClient|SoapClient */ protected function getSoapClient() { if ($this->soap === null) { // Refactor to somewhere $options = array('trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS); $this->soap = new \SoapClient($this->provider->getBaseURL() . '/' . $this->service->getServiceURI(), $options); if ($this->needsAuthentication) { $this->soap->__setSoapHeaders(array($this->provider->getAuthentication()->getHeader())); } } return $this->soap; }