public function convertXmlToPhp(SoapRequest $request, $data)
 {
     $doc = new \DOMDocument();
     $doc->loadXML($data);
     $includes = $doc->getElementsByTagNameNS('http://www.w3.org/2004/08/xop/include', 'Include');
     $include = $includes->item(0);
     $ref = $include->getAttribute('href');
     if (String::startsWith($ref, 'cid:')) {
         $cid = urldecode(substr($ref, 4));
         return $request->getSoapAttachments()->get($cid)->getContent();
     }
     return $data;
 }
 public function testMtomMessage()
 {
     $content = $this->loadRequestContentFixture('mtom/simple.txt');
     $request = new SoapRequest(array(), array(), array(), array(), array(), array(), $content);
     $request->server->set('CONTENT_TYPE', 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7";start-info="application/soap+xml"');
     $message = $request->getSoapMessage();
     $this->assertEquals(735, strlen(trim($message)));
     $this->assertEquals(1, count($request->getSoapAttachments()));
     $attachment = $request->getSoapAttachments()->get('http://tempuri.org/1/632618206527087310');
     $this->assertNotNull($attachment);
     $this->assertEquals('application/octet-stream', $attachment->getType());
     $this->assertEquals(767, strlen(trim($attachment->getContent())));
 }
 /**
  * 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];
     }
 }
 /**
  * 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)) {
         // @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);
         $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];
     }
 }