/** * Factory function for SoapResponse. * * @param string $content Content * @param string $location Location * @param string $action SOAP action * @param string $version SOAP version * * @return BeSimple\SoapClient\SoapResponse */ public static function create($content, $location, $action, $version) { $response = new SoapResponse(); $response->setContent($content); $response->setLocation($location); $response->setAction($action); $response->setVersion($version); $contentType = SoapMessage::getContentTypeForVersion($version); $response->setContentType($contentType); return $response; }
/** * Factory function for SoapRequest. * * @param string $content Content * @param string $location Location * @param string $action SOAP action * @param string $version SOAP version * * @return BeSimple\SoapClient\SoapRequest */ public static function create($content, $location, $action, $version) { $request = new SoapRequest(); // $content is if unmodified from SoapClient not a php string type! $request->setContent((string) $content); $request->setLocation($location); $request->setAction($action); $request->setVersion($version); $contentType = SoapMessage::getContentTypeForVersion($version); $request->setContentType($contentType); return $request; }
/** * This method gets called once for every SOAP header the \SoapServer received * and afterwards once for the called SOAP operation. * * @param string $method The SOAP header or SOAP operation name * @param array $arguments * * @return mixed */ public function __call($method, $arguments) { if ($this->serviceBinder->isServiceMethod($method)) { if (!empty($this->headers)) { $firstHeaderName = array_keys($this->headers)[0]; if (count($this->headers) === 1 && substr($firstHeaderName, -6) === 'Header') { // headers are wrapped and returned as stdClass! $this->headers = (array) $this->headers[$firstHeaderName]; } // @TODO Add all SoapHeaders in SoapRequest foreach ($this->headers as $name => $value) { if ($this->serviceBinder->isServiceHeader($method, $name)) { $this->soapRequest->getSoapHeaders()->add($this->serviceBinder->processServiceHeader($method, $name, $value)); } } } $this->headers = null; $this->soapRequest->attributes->add($this->serviceBinder->processServiceMethodArguments($method, $arguments)); // forward to controller $response = $this->container->get('http_kernel')->handle($this->soapRequest, HttpKernelInterface::SUB_REQUEST, false); $contentType = SoapMessage::getContentTypeForVersion($this->webserviceContext->getServiceDefinition()->getOption('version')); $response->headers->add(array('Content-Type' => $contentType)); $this->setResponse($response); // add response soap headers to soap server foreach ($response->getSoapHeaders() as $header) { $this->soapServer->addSoapHeader($header->toNativeSoapHeader()); } // return operation return value to soap server return $this->serviceBinder->processServiceMethodReturnValue($method, $response->getReturnValue()); } else { // collect request soap headers $this->headers[$method] = $arguments[0]; } }