Merge branch '0.2'
This commit is contained in:
commit
bbd4c26134
|
@ -25,7 +25,6 @@ class Cache
|
||||||
|
|
||||||
BaseCache::setEnabled($isEnabled);
|
BaseCache::setEnabled($isEnabled);
|
||||||
|
|
||||||
if (BaseCache::ENABLED == BaseCache::isEnabled()) {
|
|
||||||
BaseCache::setType($type);
|
BaseCache::setType($type);
|
||||||
BaseCache::setDirectory($directory);
|
BaseCache::setDirectory($directory);
|
||||||
|
|
||||||
|
@ -38,4 +37,3 @@ class Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -16,6 +16,7 @@
|
||||||
</argument>
|
</argument>
|
||||||
<argument type="service" id="besimple.soap.classmap" />
|
<argument type="service" id="besimple.soap.classmap" />
|
||||||
<argument type="service" id="besimple.soap.converter.collection" />
|
<argument type="service" id="besimple.soap.converter.collection" />
|
||||||
|
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />
|
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
||||||
<argument>%kernel.debug%</argument>
|
<argument>%kernel.debug%</argument>
|
||||||
<argument>%besimple.soap.cache.type%</argument>
|
<argument>%besimple.soap.cache.type%</argument>
|
||||||
<argument>%besimple.soap.cache.dir%/php</argument>
|
<argument>%besimple.soap.cache.dir%/cache</argument>
|
||||||
<argument>%besimple.soap.cache.lifetime%</argument>
|
<argument>%besimple.soap.cache.lifetime%</argument>
|
||||||
<argument>%besimple.soap.cache.limit%</argument>
|
<argument>%besimple.soap.cache.limit%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
|
@ -33,4 +33,8 @@ SoapServer
|
||||||
SoapClient
|
SoapClient
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Coming soon.
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:numbered:
|
||||||
|
|
||||||
|
soapclient/configuration
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
Minimal client configuration
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Configure your first client in your config file:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# app/config/config.yml
|
||||||
|
be_simple_soap:
|
||||||
|
clients:
|
||||||
|
DemoApi:
|
||||||
|
wsdl: http://localhost:8086/app_dev.php/ws/DemoApi?wsdl
|
||||||
|
|
||||||
|
|
||||||
|
Using client
|
||||||
|
------------
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
class DemoController extends Controller
|
||||||
|
{
|
||||||
|
public function helloAction($name)
|
||||||
|
{
|
||||||
|
// The client service name is `besimple.soap.client.demoapi`:
|
||||||
|
// `besimple.soap.client.`: is the base name of your client
|
||||||
|
// `demoapi`: is the name specified in your config file converted to lowercase
|
||||||
|
$client = $this->container->get('besimple.soap.client.demoapi');
|
||||||
|
|
||||||
|
// call `hello` method on WebService with the string parameter `$name`
|
||||||
|
$helloResult = $client->hello($name);
|
||||||
|
|
||||||
|
return $this->render('AcmeDemoBundle:Demo:hello.html.twig', array(
|
||||||
|
'hello' => $helloResult,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Classmap
|
||||||
|
--------
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# app/config/config.yml
|
||||||
|
be_simple_soap:
|
||||||
|
clients:
|
||||||
|
DemoApi:
|
||||||
|
# ...
|
||||||
|
classmap:
|
||||||
|
User: Acme\DemoBundle\Api\UserApi
|
||||||
|
# add other type_name: classname
|
||||||
|
|
||||||
|
UserApi class
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Api;
|
||||||
|
|
||||||
|
class UserApi
|
||||||
|
{
|
||||||
|
private $username;
|
||||||
|
|
||||||
|
private $firstname;
|
||||||
|
|
||||||
|
private $lastname;
|
||||||
|
|
||||||
|
public function __construct($username)
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFirstname()
|
||||||
|
{
|
||||||
|
return $this->firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastname()
|
||||||
|
{
|
||||||
|
return $this->lastname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Usage
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Controller;
|
||||||
|
|
||||||
|
use Acme\DemoBundle\Api\UserApi;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
class DemoController extends Controller
|
||||||
|
{
|
||||||
|
public function userAction($username)
|
||||||
|
{
|
||||||
|
// The client service name is `besimple.soap.client.demoapi`:
|
||||||
|
// `besimple.soap.client.`: is the base name of your client
|
||||||
|
// `demoapi`: is the name specified in your config file converted to lowercase
|
||||||
|
$client = $this->container->get('besimple.soap.client.demoapi');
|
||||||
|
|
||||||
|
// call `getUser` method on WebService with an instance of UserApi
|
||||||
|
// if the `getUserByUsername` method return a `User` type then `$userResult` is an instance of UserApi
|
||||||
|
$userResult = $client->getUserByUsername($username);
|
||||||
|
|
||||||
|
return $this->render('AcmeDemoBundle:Demo:user.html.twig', array(
|
||||||
|
'user' => $userResult,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Without classmap configuration the `$userResult` is an instance of `stdClass`:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
object(stdClass)#5561 (3) {
|
||||||
|
["username"]=>
|
||||||
|
string(6) "FooBar"
|
||||||
|
["firstname"]=>
|
||||||
|
string(3) "Foo"
|
||||||
|
["lastname"]=>
|
||||||
|
string(3) "Bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
With classmap configuration the `$userResult` is an instance of `Acme\DemoBundle\Api\UserApi`:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
object(Acme\DemoBundle\Api\UserApi)#208 (3) {
|
||||||
|
["username":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(6) "FooBar"
|
||||||
|
["firstname":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(3) "Foo"
|
||||||
|
["lastname":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(3) "Bar"
|
||||||
|
}
|
|
@ -41,15 +41,6 @@ class SoapClient extends \SoapClient
|
||||||
*/
|
*/
|
||||||
protected $tracingEnabled = false;
|
protected $tracingEnabled = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable.
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $cliWebserverWorkaround = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cURL instance.
|
* cURL instance.
|
||||||
*
|
*
|
||||||
|
@ -108,10 +99,7 @@ class SoapClient extends \SoapClient
|
||||||
if (isset($options['soap_version'])) {
|
if (isset($options['soap_version'])) {
|
||||||
$this->soapVersion = $options['soap_version'];
|
$this->soapVersion = $options['soap_version'];
|
||||||
}
|
}
|
||||||
// activate cli webserver workaround
|
|
||||||
if (isset($options['cli_webserver_workaround'])) {
|
|
||||||
$this->cliWebserverWorkaround = $options['cli_webserver_workaround'];
|
|
||||||
}
|
|
||||||
$this->curl = new Curl($options);
|
$this->curl = new Curl($options);
|
||||||
|
|
||||||
if (isset($options['extra_options'])) {
|
if (isset($options['extra_options'])) {
|
||||||
|
@ -158,25 +146,6 @@ class SoapClient extends \SoapClient
|
||||||
|
|
||||||
$location = $soapRequest->getLocation();
|
$location = $soapRequest->getLocation();
|
||||||
$content = $soapRequest->getContent();
|
$content = $soapRequest->getContent();
|
||||||
/*
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable
|
|
||||||
*/
|
|
||||||
if ($this->cliWebserverWorkaround === true) {
|
|
||||||
if (strpos($location, '?') === false) {
|
|
||||||
$location .= '?';
|
|
||||||
} else {
|
|
||||||
$location .= '&';
|
|
||||||
}
|
|
||||||
$location .= SoapMessage::CONTENT_TYPE_HEADER.'='.urlencode($soapRequest->getContentType());
|
|
||||||
$location .= '&';
|
|
||||||
$location .= SoapMessage::SOAP_ACTION_HEADER.'='.urlencode($soapRequest->getAction());
|
|
||||||
|
|
||||||
$content = http_build_query(array('request' => $content));
|
|
||||||
|
|
||||||
$headers = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$headers = $this->filterRequestHeaders($soapRequest, $headers);
|
$headers = $this->filterRequestHeaders($soapRequest, $headers);
|
||||||
|
|
||||||
|
@ -189,6 +158,7 @@ class SoapClient extends \SoapClient
|
||||||
$headers,
|
$headers,
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
|
|
||||||
// tracing enabled: store last request header and body
|
// tracing enabled: store last request header and body
|
||||||
if ($this->tracingEnabled === true) {
|
if ($this->tracingEnabled === true) {
|
||||||
$this->lastRequestHeaders = $this->curl->getRequestHeaders();
|
$this->lastRequestHeaders = $this->curl->getRequestHeaders();
|
||||||
|
|
|
@ -18,7 +18,6 @@ $options = array(
|
||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
'connection_timeout' => 1,
|
'connection_timeout' => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ class MtomServerInteropTest extends TestCase
|
||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testAttachment()
|
public function testAttachment()
|
||||||
|
|
|
@ -24,7 +24,6 @@ $options = array(
|
||||||
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
||||||
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);
|
||||||
|
|
|
@ -23,7 +23,6 @@ class SwaServerInteropTest extends TestCase
|
||||||
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
||||||
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUploadDownloadText()
|
public function testUploadDownloadText()
|
||||||
|
|
|
@ -31,7 +31,6 @@ $options = array(
|
||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $options);
|
||||||
|
|
|
@ -30,7 +30,6 @@ class WsSecuritySigEncServerInteropTest extends TestCase
|
||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testSigEnc()
|
public function testSigEnc()
|
||||||
|
|
|
@ -28,7 +28,6 @@ $options = array(
|
||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options);
|
||||||
|
|
|
@ -29,7 +29,6 @@ class WsSecurityUserPassServerInteropTest extends TestCase
|
||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUserPassText()
|
public function testUserPassText()
|
||||||
|
|
|
@ -28,6 +28,13 @@ abstract class SoapMessage
|
||||||
*/
|
*/
|
||||||
const CONTENT_TYPE_HEADER = 'CONTENT_TYPE';
|
const CONTENT_TYPE_HEADER = 'CONTENT_TYPE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $_SERVER key for 'Content-Type' header (with PHP cli-webserver)
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const HTTP_CONTENT_TYPE_HEADER = 'HTTP_CONTENT_TYPE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $_SERVER key for 'SOAPAction' header.
|
* $_SERVER key for 'SOAPAction' header.
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,29 +32,19 @@ class SoapRequest extends CommonSoapRequest
|
||||||
*/
|
*/
|
||||||
public static function create($content, $version)
|
public static function create($content, $version)
|
||||||
{
|
{
|
||||||
$location = self::getCurrentUrl();
|
|
||||||
/*
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable
|
|
||||||
*/
|
|
||||||
if (php_sapi_name() == "cli-server") {
|
|
||||||
$content = is_null($content) ? $_POST['request'] : $content;
|
|
||||||
$action = $_GET[SoapMessage::SOAP_ACTION_HEADER];
|
|
||||||
$contentType = $_GET[SoapMessage::CONTENT_TYPE_HEADER];
|
|
||||||
} else {
|
|
||||||
$content = is_null($content) ? file_get_contents("php://input") : $content;
|
|
||||||
$action = isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null;
|
|
||||||
$contentType = $_SERVER[SoapMessage::CONTENT_TYPE_HEADER];
|
|
||||||
}
|
|
||||||
|
|
||||||
$request = new SoapRequest();
|
$request = new SoapRequest();
|
||||||
|
|
||||||
// $content is if unmodified from SoapClient not a php string type!
|
// $content is if unmodified from SoapClient not a php string type!
|
||||||
$request->setContent((string) $content);
|
$request->setContent((string) (null === $content ? file_get_contents("php://input") : $content));
|
||||||
$request->setLocation($location);
|
$request->setLocation(self::getCurrentUrl());
|
||||||
$request->setAction($action);
|
$request->setAction(isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null);
|
||||||
$request->setVersion($version);
|
$request->setVersion($version);
|
||||||
$request->setContentType($contentType);
|
|
||||||
|
if (isset($_SERVER[SoapMessage::CONTENT_TYPE_HEADER])) {
|
||||||
|
$request->setContentType($_SERVER[SoapMessage::CONTENT_TYPE_HEADER]);
|
||||||
|
} elseif (isset($_SERVER[SoapMessage::HTTP_CONTENT_TYPE_HEADER])) {
|
||||||
|
$request->setContentType($_SERVER[SoapMessage::HTTP_CONTENT_TYPE_HEADER]);
|
||||||
|
}
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue