<commit_before><?php

namespace Orkestra\Common\Kernel;

use Symfony\Component\HttpFoundation\Request;
    
use Orkestra\Common\Kernel\Soap\SoapRequest,
    Orkestra\Common\Kernel\Soap\SoapResponse,
    Orkestra\Common\Exception\KernelException;

/**
 * Soap Kernel
 *
 * This kernel provides a wrapper for SoapClient to execute a given Request and return
 * a normalized Response object.
 *
 * @package Orkestra
 * @subpackage Common
 */
class SoapKernel extends KernelBase
{
    /**
     * {@inheritdoc}
     *
     * @return Orkestra\Common\Kernel\Soap\SoapResponse
     */
    public function handle(Request $request)
    {
        if (!$request instanceof SoapRequest) {
            throw new KernelException(sprintf('SoapKernel expects argument 1 to be of type Orkestra\Common\Kernel\Soap\SoapRequest, type %s given', get_class($request)));
        }
        
        try {
            $client = new \SoapClient($request->getUri(), array(
            	"trace" => true,
            	"exceptions" => true,
            ));
        
            $content = $request->getContent();
        }
        catch (\Exception $e) {
            $response = new SoapResponse($e->__toString(), $e, 'HTTP/1.1 500 Internal Server Error');
        }
        
        try {
            $data = $client->__soapCall($request->getSoapAction(), $content);
        }
        catch (\Exception $e) {
            $data = $e;
        }
        
        $this->_log('SoapKernel: Request to ' . $request->getUri());
        $this->_log('SoapKernel: Request: ' . $client->__getLastRequest());
        $this->_log('SoapKernel: Response: ' . $client->__getLastResponse());
        
        $header = $client->__getLastResponseHeaders();
        $raw = $client->__getLastResponse();

        $response = new SoapResponse($raw, $data, $header);
        
        return $response;
    }
}<commit_msg>Fixed bug in SoapKernel where an exception was not handled properly if the SoapClient fails to initialize. fixes #886<commit_after><?php

namespace Orkestra\Common\Kernel;

use Symfony\Component\HttpFoundation\Request;
    
use Orkestra\Common\Kernel\Soap\SoapRequest,
    Orkestra\Common\Kernel\Soap\SoapResponse,
    Orkestra\Common\Exception\KernelException;

/**
 * Soap Kernel
 *
 * This kernel provides a wrapper for SoapClient to execute a given Request and return
 * a normalized Response object.
 *
 * @package Orkestra
 * @subpackage Common
 */
class SoapKernel extends KernelBase
{
    /**
     * {@inheritdoc}
     *
     * @return Orkestra\Common\Kernel\Soap\SoapResponse
     */
    public function handle(Request $request)
    {
        if (!$request instanceof SoapRequest) {
            throw new KernelException(sprintf('SoapKernel expects argument 1 to be of type Orkestra\Common\Kernel\Soap\SoapRequest, type %s given', get_class($request)));
        }
        
        try {
            $client = new \SoapClient($request->getUri(), array(
            	"trace" => true,
            	"exceptions" => true,
            ));
        
            $content = $request->getContent();

            try {
                $data = $client->__soapCall($request->getSoapAction(), $content);
            }
            catch (\Exception $e) {
                $data = $e;
            }

            $this->_log('SoapKernel: Request to ' . $request->getUri());
            $this->_log('SoapKernel: Request: ' . $client->__getLastRequest());
            $this->_log('SoapKernel: Response: ' . $client->__getLastResponse());

            $header = $client->__getLastResponseHeaders();
            $raw = $client->__getLastResponse();

            $response = new SoapResponse($raw, $data, $header);
        }
        catch (\Exception $e) {
            $response = new SoapResponse($e->__toString(), $e, 'HTTP/1.1 500 Internal Server Error');
        }

        return $response;
    }
}
{'fraction_non_alphanumeric': 0.12804561949196475, 'fraction_numerical': 0.0038880248833592537, 'mean_word_length': 2.275891341256367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4029861', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1109, 'n_words': 250}