我正试图在Symfony中创建一个web服务。我看过这些网,都试过了,但它们不适合我。
http://besim.pl/SoapBundle/soapserver/configuration.html http://barandigoyen.wordpress.com/2012/07/13/como-implementar-un-web-service-wsdl-en-symfony-2/
有谁能更好地解释这个过程,一步一步地解释一下吗?
非常感谢!
编辑:我遵循的步骤如下:
1)将以下内容添加到composer.json中
"require":{
...
"besimple/soap-bundle": "dev-master",
"besimple/soap-common": "dev-master",
"ass/xmlsecurity": "dev-master",
"besimple/soap-server": "dev-master",
"besimple/soap-client": "dev-master"
...
}2)运行以下命令:
$ php composer.phar self-update
$ php composer.phar update3)在app/AppKernel.php中添加了以下内容
public function registerBundles()
{
return array(
// ...
new BeSimple\SoapBundle\BeSimpleSoapBundle(),
// ...
);
}4)在app/config/config.yml中添加以下内容
be_simple_soap:
cache:
type: disk
lifetime: 86400
limit: 5
services:
AplicationService:
namespace: http://localhost/myproject/web/app_dev.php/ws/AplicationService
binding: rpc-literal
resource: “@StaticBundle/Controller/WebServiceController.php“
resource_type: annotation5)在app/config/routing.yml中添加以下内容
_besimple_soap:
resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
prefix: /ws6)在StaticBundle中创建以下控制器
namespace myproject\StaticBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class WebServiceController extends Controller
{
/**
* @Soap\Method("hello")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function helloAction($name)
{
return sprintf('Hello %s!', $name);
}
/**
* @Soap\Method("goodbye")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function goodbyeAction($name)
{
return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Goodbye %s!', $name));
}
}7)访问localhost/myproject/web/app_dev.php/ws/AplicationService?wsdl并获得错误代码为500的xml。
发布于 2014-11-27 17:07:28
好吧,检查日志,我发现了这个问题的原因:更正config.yml的双引号:
resource: "@StaticBundle/Controller/WebServiceController.php"他们的榜样有奇怪的双引号;)
发布于 2014-10-28 19:49:11
在步骤6中,您似乎在注释中遗漏了Soap的use语句。http://besim.pl/SoapBundle/soapserver/configuration.html#annotations-for-controllers
尝试:
namespace myproject\StaticBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
class WebServiceController extends Controller
{
/**
* @Soap\Method("hello")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function helloAction($name)
{
return sprintf('Hello %s!', $name);
}
/**
* @Soap\Method("goodbye")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function goodbyeAction($name)
{
return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Goodbye %s!', $name));
}
}https://stackoverflow.com/questions/24820703
复制相似问题