我将nuSoap与Symfony一起使用
接收动作有效:
http://127.0.0.1:8000/recept?wsdl 我得到xml模式。...
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://127.0.0.1:8000/recept" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="App.Service.SoapDataService" targetNamespace="http://127.0.0.1:8000/recept">
..........
/**
* @Route("/recept", methods={"GET"}, name="default_recept")
*/
public function recept(Request $request, SoapDataService $soapDataService, ParameterBagInterface $params): Response
{
$path = $params->get('root_dir');
$filename = $path . "/../public/hello.wsdl";
$gen = new \PHP2WSDL\PHPClass2WSDL($soapDataService, "http://127.0.0.1:8000/recept");
$gen->generateWSDL();
$gen->save($filename);
$soapServer = new \SoapServer($filename);
$soapServer->setObject($soapDataService);
$response = new Response();
$response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
ob_start();
$soapServer->handle();
$response->setContent(ob_get_clean());
return $response;
}
但是带有服务器Soap的客户端他不工作!
/**
* @Route("/client", methods={"GET"}, name="default_client")
*/
public function client(Request $request, SoapDataService $soapDataService, ParameterBagInterface $params): Response
{
$path = $params->get('root_dir');
$filename = $path . "/../public/hello.wsdl";
$soapClient = new \SoapClient('http://127.0.0.1:8000/recept?wsdl');
$result = $soapClient->call('hello');
dump($result);
}
在此行:
$result = $soapClient->call('hello');
它仍然没有执行任何操作 超过120秒的最大执行时间
namespace App\Service;
class SoapDataService
{
public function __construct()
{
}
public function hello($name)
{
return 'Hello, '.$name;
}
}
帮助!
使用\ Zend \ Soap \ Server
进行测试 $server = new \Zend\Soap\Server('http://127.0.0.1:8000/recept?wsdl', $options);
$server->setObject($soapDataService);
$server->handle();
$server->setReturnResponse(true);
120秒后: SOAP错误:解析WSDL:无法从'http://127.0.0.1:8000/recept?wsdl'加载:无法加载外部实体“ http://127.0.0.1:8000/recept?wsdl”