Added besimple.soap.response service
It is highly recommended not to instantiate BeSimple\SoapBundle\Soap\SoapResponse but to use the service besimple.soap.response Before: public function helloAction($name) { return new SoapResponse("Hello ".$name); } After: public function helloAction($name) { return $this ->container ->get('besimple.soap.response') ->setReturnValue("Hello ".$name) ; }
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="besimple.soap.response.class">BeSimple\SoapBundle\Soap\SoapResponse</parameter>
|
||||
<parameter key="besimple.soap.context.class">BeSimple\SoapBundle\WebServiceContext</parameter>
|
||||
<parameter key="besimple.soap.cache_dir">%kernel.cache_dir%/webservice</parameter>
|
||||
<parameter key="besimple.soap.binder.request_header.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestHeaderMessageBinder</parameter>
|
||||
@ -17,6 +18,8 @@
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="besimple.soap.response" class="%besimple.soap.response.class%" />
|
||||
|
||||
<service id="besimple.soap.context.rpcliteral" class="%besimple.soap.context.class%" abstract="true">
|
||||
<argument type="service" id="besimple.soap.definition.loader" />
|
||||
<argument type="service" id="besimple.soap.definition.dumper.wsdl.rpcliteral" />
|
||||
|
@ -34,18 +34,20 @@ Annotations for Controllers
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
namespace My\App\Controller;
|
||||
|
||||
class DemoController extends Controller
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
|
||||
class DemoController extends ContainerAware
|
||||
{
|
||||
/**
|
||||
* @Soap\Method("Hello")
|
||||
* @Soap\Method("hello")
|
||||
* @Soap\Param("name", phpType = "string")
|
||||
* @Soap\Result(phpType = "string")
|
||||
*/
|
||||
public function helloAction($name)
|
||||
{
|
||||
return new SoapResponse(sprintf('Hello %s!', $name));
|
||||
return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Hello %s!', $name));
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ Controller
|
||||
namespace My\App\Controller;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
|
||||
class DemoController extends ContainerAware
|
||||
@ -21,6 +20,6 @@ Controller
|
||||
*/
|
||||
public function helloAction(array $names)
|
||||
{
|
||||
return new SoapResponse("Hello ".implode(', ', $names));
|
||||
return $this->container->get('besimple.soap.response')->setReturnValue("Hello ".implode(', ', $names));
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ Controller
|
||||
namespace My\App\Controller;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
|
||||
class DemoController extends ContainerAware
|
||||
@ -29,13 +28,13 @@ Controller
|
||||
{
|
||||
$user = $this->container->getDoctrine()->getRepository('MyApp:User')->findOneBy(array(
|
||||
'name' => $name,
|
||||
);
|
||||
));
|
||||
|
||||
if (!$user) {
|
||||
throw new \SoapFault('USER_NOT_FOUND', sprintf('The user with the name "%s" can not be found', $name));
|
||||
}
|
||||
|
||||
return new SoapResponse($user);
|
||||
return $this->container->get('besimple.soap.response')->setReturnValue($user);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ Controller
|
||||
namespace My\App\Controller;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
|
||||
class DemoController extends ContainerAware
|
||||
@ -27,6 +26,6 @@ Controller
|
||||
throw new \SoapFault("INVALID_API_KEY", "The api_key is invalid.");
|
||||
}
|
||||
|
||||
return new SoapResponse("Hello ".implode(', ', $names));
|
||||
return $this->container->get('besimple.soap.response')->setReturnValue("Hello ".implode(', ', $names));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user