[英]How create a service using soap and symfony2
我想使用soap和Symfony2創建一個Web服務,但是它給我以下錯誤:無法連接到主機
這是我的代碼:
<?php
namespace Acme\DemoBundle\Services;
class HelloService
{
private $message;
public function __construct()
{
$this->message = "Hola";
}
public function hello($name)
{
return $this->message+$name;
}
}
?>
#app/config/config.yml
services:
hello_service:
class: Acme\DemoBundle\Services\HelloService
#app/config/routing.yml
servicio:
pattern: /soap
defaults: {_controller:AcmeDemoBundle:Demo:service}
cliente:
pattern: /cliente
defaults: {_controller:AcmeDemoBundle:Demo:cliente}
public function serviceAction() {
$server = new \SoapServer('http://example.com/src/Acme/DemoBundle/Resources/views/Demo/hello.wsdl');
$server->setObject($this->get('hello_service'));
$response = new Response();
$response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
ob_start();
$server->handle();
$response->setContent(ob_get_clean());
}
public function clienteAction(){
$client = new \Soapclient('http://example.com/web/app_dev.php/soap?wsdl');
$result = $client->call('hello', array('name' => 'Scott'));
}
瀏覽器中的URL是: http : //example.com/web/app_dev.php/cliente可能是什么問題?
我通過擦除緩存ini_set('soap.wsdl_cache_enabled',0);解決了這個問題。 ini_set('soap.wsdl_cache_ttl',0);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.