public function testUploadDownloadImage()
 {
     $sc = new BeSimpleSoapClient(__DIR__ . '/Fixtures/SwA.wsdl', $this->options);
     $upload = new uploadFile();
     $upload->name = 'image.jpg';
     $upload->data = file_get_contents(__DIR__ . '/Fixtures/image.jpg');
     // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg;
     $result = $sc->uploadFile($upload);
     $this->assertEquals('File saved succesfully.', $result->return);
     $download = new downloadFile();
     $download->name = 'image.jpg';
     $result = $sc->downloadFile($download);
     $this->assertEquals($upload->data, $result->data);
 }
<?php

require '../../../../../vendor/autoload.php';
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile;
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse;
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFile;
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFileResponse;
use BeSimple\SoapClient\Tests\ServerInterop\TestCase;
$options = array('soap_version' => SOAP_1_1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, 'cache_wsdl' => WSDL_CACHE_NONE, 'trace' => true, 'classmap' => array('downloadFile' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\downloadFile', 'downloadFileResponse' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\downloadFileResponse', 'uploadFile' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\uploadFile', 'uploadFileResponse' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\uploadFileResponse'), 'cli_webserver_workaround' => true);
$sc = new BeSimpleSoapClient(__DIR__ . '/Fixtures/SwA.wsdl', $options);
try {
    $upload = new uploadFile();
    $upload->name = 'upload.txt';
    $upload->data = 'This is a test. :)';
    $result = $sc->uploadFile($upload);
    var_dump($result);
    $download = new downloadFile();
    $download->name = 'upload.txt';
    var_dump($sc->downloadFile($download));
} catch (Exception $e) {
    var_dump($e);
}
// var_dump(
//     $sc->__getLastRequestHeaders(),
//     $sc->__getLastRequest(),
//     $sc->__getLastResponseHeaders(),
//     $sc->__getLastResponse()
// );
Example #3
0
 *
 * Doesn't work directly with ?wsdl served by Apache Axis!
 *
 */
$sc = new BeSimpleSoapClient('SwA.wsdl', $options);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
    $file = new stdClass();
    $file->name = 'upload.txt';
    $file->data = 'This is a test text!';
    $result = $sc->uploadFile($file);
    var_dump($result->return);
    $file = new stdClass();
    $file->name = 'upload.txt';
    $result = $sc->downloadFile($file);
    var_dump($result->data);
    $file = new stdClass();
    $file->name = 'image.jpg';
    // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg
    $file->data = file_get_contents('image.jpg');
    $result = $sc->uploadFile($file);
    var_dump($result->return);
    $crc32 = crc32($file->data);
    $file = new stdClass();
    $file->name = 'image.jpg';
    $result = $sc->downloadFile($file);
    file_put_contents('image2.jpg', $result->data);
    var_dump(crc32($result->data) === $crc32);
} catch (Exception $e) {
    var_dump($e);