I never managed to make native PHP SoapServer class to handle "understand" soap:Security header as expected with mustUnderstand attribute. But some WS tools like SoapUI automatically set it to "true" or "1" and I needed to make a work around to avoid Soap Fault : "SOAP-ENV:MustUnderstand / Header not understood"
Here is a controller action that inhib mustUnderstand attribute :
public function ordersFollowUpAction() { $request = $this->getRequest(); //This deletes mustUnderstand attribute from raw request content $decodedRequest = preg_replace('/ ([-\w]+\:)?(mustUnderstand=")(1|true)(")/', '', $request->getContent()); $server = new \SoapServer(__DIR__ . '/../Resources/public/wsdl/MyWsdl.wsdl'); $server->setObject($this->get('my_webservice')); $response = new Response(); $response->headers->set('Content-Type', 'text/xml; charset=UTF-8'); try { ob_start(); //This explicitely passes clear request content to the service handler $server->handle($decodedRequest); $response->setContent(@ob_get_clean()); } catch (\Exception $e) { $this->get('logger')->err($e->getMessage()); $response->setContent('An error occured, please contact our support service.'); } return $response; }
No comments :
Post a Comment
Comments are moderated before being published.