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
.
In client.php, change this:
to this:
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.
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.