Php 如何使用soap和symfony2创建服务
我想使用soap和Symfony2创建web服务,但它给出了以下错误: 无法连接到主机 这是我的代码:Php 如何使用soap和symfony2创建服务,php,symfony,soap,Php,Symfony,Soap,我想使用soap和Symfony2创建web服务,但它给出了以下错误: 无法连接到主机 这是我的代码: <?php namespace Acme\DemoBundle\Services; class HelloService { private $message; public function __construct() { $this->message = "Hola"; } public function h
<?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'));
}
#app/config/config.yml
服务:
你好![2]服务:
类:Acme\DemoBundle\Services\HelloService
#app/config/routing.yml
服务:
模式:/soap
默认值:{u控制器:AcmeDemoBundle:Demo:service}
客户:
模式:/cliente
默认值:{u控制器:AcmeDemoBundle:Demo:cliente}
公共职能服务行动(){
$server=new\SoapServer('s)http://example.com/src/Acme/DemoBundle/Resources/views/Demo/hello.wsdl');
$server->setObject($this->get('hello_service'));
$response=新响应();
$response->headers->set('Content-Type','text/xml;charset=ISO-8859-1');
ob_start();
$server->handle();
$response->setContent(ob_get_clean());
}
公共职能客户行动(){
$client=new\Soapclient('http://example.com/web/app_dev.php/soap?wsdl');
$result=$client->call('hello',array('name'=>'Scott');
}
浏览器中的url为:
可能有什么问题?我通过擦除缓存ini\u集(“soap.wsdl\u cache\u enabled”,0)解决了这个问题;ini\u集('soap.wsdl\u缓存\u ttl',0) 是否返回有效的XML wsdl?我通过擦除缓存ini\u集(“soap.wsdl\u cache\u enabled”,0)解决了这个问题;ini\u集('soap.wsdl\u缓存\u ttl',0);请你把你的发现作为答案,然后接受它好吗?