Ejemplo n.º 1
0
 /**
  * Finally returns a SoapClient instance.
  *
  * @return \BeSimple\SoapServer\SoapServer
  */
 public function build()
 {
     $this->validateOptions();
     use_soap_error_handler($this->errorReporting);
     $server = new SoapServer($this->wsdl, $this->getSoapOptions());
     if (null !== $this->persistence) {
         $server->setPersistence($this->persistence);
     }
     if (null !== $this->handlerClass) {
         $server->setClass($this->handlerClass);
     } elseif (null !== $this->handlerObject) {
         $server->setObject($this->handlerObject);
     }
     return $server;
 }
Ejemplo n.º 2
0
 /**
  * Runs the currently registered request filters on the request, calls the
  * necessary functions (through the parent's class handle()) and runs the
  * response filters.
  *
  * @param SoapRequest $soapRequest SOAP request object
  *
  * @return SoapResponse
  */
 public function handle2(SoapRequest $soapRequest)
 {
     // run SoapKernel on SoapRequest
     $this->soapKernel->filterRequest($soapRequest);
     // call parent \SoapServer->handle() and buffer output
     ob_start();
     parent::handle($soapRequest->getContent());
     $response = ob_get_clean();
     // wrap response data in SoapResponse object
     $soapResponse = SoapResponse::create($response, $soapRequest->getLocation(), $soapRequest->getAction(), $soapRequest->getVersion());
     // run SoapKernel on SoapResponse
     $this->soapKernel->filterResponse($soapResponse);
     return $soapResponse;
 }
        }
        return null;
    }
}
class WsSecurityUserPassServer
{
    public function getBook(getBook $gb)
    {
        $bi = new BookInformation();
        $bi->isbn = $gb->isbn;
        $bi->title = 'title';
        $bi->author = 'author';
        $bi->type = 'scifi';
        $br = new getBookResponse();
        $br->getBookReturn = $bi;
        return $br;
    }
    public function addBook(addBook $ab)
    {
        $abr = new addBookResponse();
        $abr->addBookReturn = true;
        return $abr;
    }
}
$ss = new BeSimpleSoapServer(__DIR__ . '/Fixtures/WsSecurityUserPass.wsdl', $options);
$wssFilter = new BeSimpleWsSecurityFilter();
$wssFilter->setUsernamePasswordCallback(array('Auth', 'usernamePasswordCallback'));
$soapKernel = $ss->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
$ss->setClass('WsSecurityUserPassServer');
$ss->handle();
Ejemplo n.º 4
0
<?php

require '../../../../../vendor/autoload.php';
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapServer\SoapServer as BeSimpleSoapServer;
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
$options = array('soap_version' => SOAP_1_1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM, 'cache_wsdl' => WSDL_CACHE_NONE, 'classmap' => array('base64Binary' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\base64Binary', 'AttachmentRequest' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\AttachmentRequest'));
class Mtom
{
    public function attachment(AttachmentRequest $attachment)
    {
        $b64 = $attachment->binaryData;
        file_put_contents(__DIR__ . '/' . $attachment->fileName, $b64->_);
        return 'File saved succesfully.';
    }
}
$ss = new BeSimpleSoapServer(__DIR__ . '/Fixtures/MTOM.wsdl', $options);
$ss->setClass('Mtom');
$ss->handle();
Ejemplo n.º 5
0
<?php

require '../../../../../vendor/autoload.php';
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapServer\SoapServer as BeSimpleSoapServer;
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;
$options = array('soap_version' => SOAP_1_1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, 'cache_wsdl' => WSDL_CACHE_NONE, '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'));
class SwA
{
    public function uploadFile(uploadFile $uploadFile)
    {
        file_put_contents(__DIR__ . '/' . $uploadFile->name, $uploadFile->data);
        $ufr = new uploadFileResponse();
        $ufr->return = 'File saved succesfully.';
        return $ufr;
    }
    public function downloadFile(downloadFile $downloadFile)
    {
        $dfr = new downloadFileResponse();
        $dfr->data = file_get_contents(__DIR__ . '/' . $downloadFile->name);
        return $dfr;
    }
}
$ss = new BeSimpleSoapServer(__DIR__ . '/Fixtures/SwA.wsdl', $options);
$ss->setClass('SwA');
$ss->handle();
        $bi->isbn = $gb->isbn;
        $bi->title = 'title';
        $bi->author = 'author';
        $bi->type = 'scifi';
        $br = new getBookResponse();
        $br->getBookReturn = $bi;
        return $br;
    }
    public function addBook(addBook $ab)
    {
        $abr = new addBookResponse();
        $abr->addBookReturn = true;
        return $abr;
    }
}
$ss = new BeSimpleSoapServer(__DIR__ . '/Fixtures/WsSecurityUserPass.wsdl', $options);
$wssFilter = new BeSimpleWsSecurityFilter();
// user key for signature and encryption
$securityKeyUser = new BeSimpleWsSecurityKey();
$securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/serverkey.pem', true);
$securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/servercert.pem', true);
$wssFilter->setUserSecurityKeyObject($securityKeyUser);
// service key for encryption
$securityKeyService = new BeSimpleWsSecurityKey();
$securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
$securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__ . '/Fixtures/clientcert.pem', true);
$wssFilter->setServiceSecurityKeyObject($securityKeyService);
// TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
$wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
$wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
$soapKernel = $ss->getSoapKernel();