[SoapBundle] Added new request format (soap, wsdl) and used them in routing
This commit is contained in:
parent
b83c1d5b1f
commit
ad82f752f7
|
@ -92,10 +92,8 @@ class SoapWebServiceController extends ContainerAware
|
||||||
));
|
));
|
||||||
|
|
||||||
$query = $this->container->get('request')->query;
|
$query = $this->container->get('request')->query;
|
||||||
if ($query->has('wsdl') || $query->has('WSDL')) {
|
if (!$query->has('wsdl') && !$query->has('WSDL')) {
|
||||||
$response->headers->set('Content-Type', 'application/wsdl+xml');
|
$this->container->get('request')->setRequestFormat('xml');
|
||||||
} else {
|
|
||||||
$response->headers->set('Content-Type', 'text/xml');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
|
@ -40,6 +40,8 @@ class BeSimpleSoapExtension extends Extension
|
||||||
{
|
{
|
||||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||||
|
|
||||||
|
$loader->load('request.xml');
|
||||||
|
|
||||||
$loader->load('loaders.xml');
|
$loader->load('loaders.xml');
|
||||||
$loader->load('converters.xml');
|
$loader->load('converters.xml');
|
||||||
$loader->load('webservice.xml');
|
$loader->load('webservice.xml');
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeSimple\SoapBundle\EventListener;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
|
||||||
|
class RequestFormatListener
|
||||||
|
{
|
||||||
|
public function onKernelRequest(GetResponseEvent $event)
|
||||||
|
{
|
||||||
|
$event->getRequest()->setFormat('wsdl', 'application/wsdl+xml');
|
||||||
|
$event->getRequest()->setFormat('soap', 'application/soap+xml');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
|
<parameters>
|
||||||
|
<parameter key="besimple.soap.request_format.listener.class">BeSimple\SoapBundle\EventListener\RequestFormatListener</parameter>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<services>
|
||||||
|
<service id="besimple.soap.request_format.listener" class="%besimple.soap.request_format.listener.class%">
|
||||||
|
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" />
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
|
||||||
|
</container>
|
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
<route id="_webservice_call" pattern="/{webservice}">
|
<route id="_webservice_call" pattern="/{webservice}">
|
||||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
||||||
<default key="_format">xml</default>
|
<default key="_format">soap</default>
|
||||||
<requirement key="_method">POST</requirement>
|
<requirement key="_method">POST</requirement>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="_webservice_definition" pattern="/{webservice}">
|
<route id="_webservice_definition" pattern="/{webservice}">
|
||||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
||||||
<default key="_format">xml</default>
|
<default key="_format">wsdl</default>
|
||||||
<requirement key="_method">GET</requirement>
|
<requirement key="_method">GET</requirement>
|
||||||
</route>
|
</route>
|
||||||
</routes>
|
</routes>
|
||||||
|
|
Loading…
Reference in New Issue