[英]symfony2 SoapServer EntityManager injection in service
我在symfony2中使用本机php SoapServer遇到了问题。 SoapServer在symfony2中使用“ UserService”服务类,应使用注入的symfony2 EntityManager实例化它,以便我可以访问“ UserRepository”。
澄清:
肥皂服务器:
$oSOAPServer = new \SoapServer('/path/to/wsdl');
$oSOAPServer->setClass("my\Namespace\UserService");
$oSOAPServer->handle();
服务:
use \Doctrine\ORM\EntityManager as EntityManager;
class UserService
{
protected $em;
public function __construct(EntityManager $em) {
$this->em = $em;
}
...
问题是:SoapServer总是返回内部服务器错误。 该服务本身直接在symfony2中调用。 当SoapServer调用/实例化时,是否甚至可以注入EntityManager?
提前致谢!
马丁
除了使用SoapServer::setClass()
还可以使用SoapServer::setObject()
并在以下位置传递服务:
$oSOAPServer = new \SoapServer('/path/to/wsdl');
$oSOAPServer->setObject($container->get('my_service'));
$oSOAPServer->handle();
Symfony文档中记录了实现肥皂服务器的方法: 如何在Symfony2控制器中创建SOAP Web服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.