[英]Web Service NuSOAP laravel 4
I am developing a web service with NuSOAP in Laravel 4. 我正在Laravel 4中使用NuSOAP开发Web服务。
The class that I'm using is https://github.com/noiselabs/NoiselabsNuSOAPBundle . 我正在使用的类是https://github.com/noiselabs/NoiselabsNuSOAPBundle 。
Server 服务器
Route::any('ws/server', function()
{
$server = new \soap_server;
$server->configureWSDL('server.hello','urn:server.hello', Request::url());
$server->wsdl->schemaTargetNamespace = 'urn:server.hello';
$server->register('hello',
array('name' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:server.hello',
'urn:server.hello#hello',
'rpc',
'encoded',
'Retorna o nome'
);
function hello($name)
{
return 'Hello '.$name;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
return Response::make($server->service($HTTP_RAW_POST_DATA), 200, array('Content-Type' => 'text/xml; charset=ISO-8859-1'));
});
Client 客户
Route::get('ws/client/hello', function()
{
$client = new \nusoap_client('http://localhost/teste_laravel/public/ws/server?wsdl', true);
$err = $client->getError();
if ($err)
{
echo "Erro no construtor<pre>".$err."</pre>";
}
$result = $client->call('hello',array('Renato'));
if ($client->fault)
{
echo "Falha<pre>".print_r($result)."</pre>";
}
else
{
$err = $client->getError();
if ($err)
{
echo "Erro<pre>".print_r($err)."</pre>";
}
else
{
print_r($result);
}
}
});
This error is returned. 返回此错误。
Array ( [faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => error in msg parsing: xml was empty, didn't parse! [detail] => ) Falha 1 数组([faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => msg解析错误:xml为空,未解析![详细信息=>)Falha 1
When I do with pure PHP server and the client with the right Laravel. 当我使用纯PHP服务器和具有正确Laravel的客户端时。
$HTTP_RAW_POST_DATA
is not always populated depending on your PHP config ( http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data ). 根据您的PHP配置( http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data ),并不总是填充
$HTTP_RAW_POST_DATA
。 You could try this instead: 您可以尝试以下方法:
$rawPostData = file_get_contents("php://input");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.