PHP SOAP 传输文件
我正在尝试学习如何使用 PHP 和 SOAP 在客户端和服务器之间传输文件(.zip 文件)。目前我的设置看起来像这样:
require('libraries/nusoap/nusoap.php');
$server = new nusoap_server;
$server->configureWSDL('server', 'urn:server');
$server->wsdl->schemaTargetNamespace = 'urn:server';
$server->register('sendFile',
array('value' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:server',
'urn:server#sendFile');
但我不确定如果不是字符串,返回类型应该是什么?我正在考虑使用 base64_encode
。
I am trying to learn how to transfer files (.zip files) between a client and server using PHP and SOAP. Currently I have a set up that looks something like this:
require('libraries/nusoap/nusoap.php');
$server = new nusoap_server;
$server->configureWSDL('server', 'urn:server');
$server->wsdl->schemaTargetNamespace = 'urn:server';
$server->register('sendFile',
array('value' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:server',
'urn:server#sendFile');
But I am unsure on what the return type should be if not a string? I am thinking of using a base64_encode
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了更清楚起见,我发布了 server.php 代码和 client.php 代码。请参见下面:
## server.php ##
=========================================== ==============================
## client.php ##
============= ======================================
您需要做的就是下载 nusoap.php,它将在肥皂库中看到 http://sourceforge.net/projects/nusoap/
这已经过充分测试,它将 100% 工作,无需失败。
To be more clear I have posted both the server.php code and client.php code. Please see below:
## server.php ##
=====================================================================
## client.php ##
=================================================
All you need to do is download the nusoap.php which will be seen in soap library http://sourceforge.net/projects/nusoap/
This is fully tested and it will 100% work without fail.
在 client.php 中,将以下内容更改
为:
In client.php, change this:
to this:
通过 SOAP 传输文件对于每个人(包括我自己)来说都是第一次。您需要打开并读取文档,然后将其作为字符串传输。我就是这样做的。
然后通过 SOAP 将 $contents 作为字符串发送,并在另一端重新组装它。
Transferring files over SOAP is something that gets everybody the first time (myself included). You need to open and read the document and then transfer it as a string. Here's how I would do it.
Then send $contents as your string through SOAP and reassemble it on the other side.