[英]Nusoap, return array of data as XML in web service
I have a PHP soap server (Using nuSoap), and a Java client (using Axis2). 我有一个PHP soap服务器(使用nuSoap)和一个Java客户端(使用Axis2)。 Which works pretty good, until it doesn't.
效果很好,直到没有效果为止。
The gist of what I'm trying to do is send a code to the service, and return a XML list of file names. 我要执行的操作的要旨是将代码发送到服务,并返回文件名的XML列表。
<filename>20120413.zip</filename>
Here's the SSCE 这是SSCE
<?
require_once('nusoap/lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('Download Database Backup', 'urn:downloadDatabase');
$server->register('getBackupFileNames', // method
array('herdCode' => 'xsd:string'), // input parameters
array('fileList' => 'xsd:string'), // output parameters
'urn:uploadDatabase', // namespace
'urn:uploadDatabase#uploadDatabase', // soapaction
'rpc', // style
'encoded', // use
'uploadDatabase' // documentation
);
function getBackupFileNames($herdCode)
{
$location = "/home/rhythms/backups/" . $herdCode;
$fileList = scandir($location);
return $fileList;
}//end function
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
In a pinch, I know I could do a foreach and manually create the XML as a string. 关键时刻,我知道我可以进行一次foreach并手动将XML创建为字符串。 However it gets XMLEncoded then.
但是,它随后得到了XMLEncoded。 Is there a better way?
有没有更好的办法? I would like to publish it by default in the WSDL.
我想默认在WSDL中发布它。 I've also tried the complexType but I had trouble handling that on the Axis2 side.
我也尝试过complexType,但是在Axis2方面却遇到了麻烦。
Thank you! 谢谢!
This isn't a direct answer. 这不是直接的答案。 What I've come to is you can send a SOAP array using the SOAP-ARRAY complex data type.
我要说的是,您可以使用SOAP-ARRAY复杂数据类型发送SOAP数组。 But it's not a very good method.
但这不是一个很好的方法。 Instead I'm going to investigate the native SOAP implementation that PHP provides.
相反,我将研究PHP提供的本机SOAP实现。
Axis2 doesn't handle the SOAP-ARRAY complex datatype well, so I think it will be easier to adjust my implementation to PHP's native types. Axis2不能很好地处理SOAP-ARRAY复杂数据类型,因此我认为将实现调整为PHP的本机类型会更容易。
This is left as a footnote so hopefully someone else won't fall down the same well I did as I was trying to find a good SOAP implementation. 这只是一个脚注,因此希望其他人不会像我试图找到一个好的SOAP实现那样失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.