diff --git a/src/BeSimple/SoapClient/SoapClient.php b/src/BeSimple/SoapClient/SoapClient.php index eb05b6d..0fa3c7d 100644 --- a/src/BeSimple/SoapClient/SoapClient.php +++ b/src/BeSimple/SoapClient/SoapClient.php @@ -41,15 +41,6 @@ class SoapClient extends \SoapClient */ 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. * @@ -108,10 +99,7 @@ class SoapClient extends \SoapClient if (isset($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); if (isset($options['extra_options'])) { @@ -158,25 +146,6 @@ class SoapClient extends \SoapClient $location = $soapRequest->getLocation(); $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); @@ -189,6 +158,7 @@ class SoapClient extends \SoapClient $headers, $options ); + // tracing enabled: store last request header and body if ($this->tracingEnabled === true) { $this->lastRequestHeaders = $this->curl->getRequestHeaders(); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php index 45b72de..df5c5e9 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php @@ -18,7 +18,6 @@ $options = array( 'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary', '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, ); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php index 7277bed..779313f 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php @@ -20,7 +20,6 @@ class MtomServerInteropTest extends TestCase 'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary', '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() diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php index 054fefe..96f34fd 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php @@ -24,7 +24,6 @@ $options = array( 'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile', '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); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php index 73dc2aa..5f3e6f3 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php @@ -23,7 +23,6 @@ class SwaServerInteropTest extends TestCase 'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile', '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() diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php index 6c7fe1d..1d529d6 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php @@ -31,7 +31,6 @@ $options = array( 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', '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); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php index 7cbbef4..0ff0142 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php @@ -30,7 +30,6 @@ class WsSecuritySigEncServerInteropTest extends TestCase 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', '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() diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php index b69b3d9..90cf534 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php @@ -28,7 +28,6 @@ $options = array( 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', '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); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php index 4030507..1df839c 100644 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php +++ b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php @@ -29,7 +29,6 @@ class WsSecurityUserPassServerInteropTest extends TestCase 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', '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() diff --git a/src/BeSimple/SoapCommon/SoapMessage.php b/src/BeSimple/SoapCommon/SoapMessage.php index 6601bc1..1b91c1a 100644 --- a/src/BeSimple/SoapCommon/SoapMessage.php +++ b/src/BeSimple/SoapCommon/SoapMessage.php @@ -28,6 +28,13 @@ abstract class SoapMessage */ 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. * diff --git a/src/BeSimple/SoapServer/SoapRequest.php b/src/BeSimple/SoapServer/SoapRequest.php index 3d410f5..7fae123 100644 --- a/src/BeSimple/SoapServer/SoapRequest.php +++ b/src/BeSimple/SoapServer/SoapRequest.php @@ -32,29 +32,19 @@ class SoapRequest extends CommonSoapRequest */ 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(); + // $content is if unmodified from SoapClient not a php string type! - $request->setContent((string) $content); - $request->setLocation($location); - $request->setAction($action); + $request->setContent((string) (null === $content ? file_get_contents("php://input") : $content)); + $request->setLocation(self::getCurrentUrl()); + $request->setAction(isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null); $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; }