SoapRequest is now SoapRequestFactory product
This commit is contained in:
parent
3c0f731086
commit
155aa029ce
|
@ -17,6 +17,7 @@ use BeSimple\SoapCommon\Converter\MtomTypeConverter;
|
||||||
use BeSimple\SoapCommon\Converter\SwaTypeConverter;
|
use BeSimple\SoapCommon\Converter\SwaTypeConverter;
|
||||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||||
use BeSimple\SoapCommon\SoapRequest;
|
use BeSimple\SoapCommon\SoapRequest;
|
||||||
|
use BeSimple\SoapCommon\SoapRequestFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended SoapClient that uses a a cURL wrapper for all underlying HTTP
|
* Extended SoapClient that uses a a cURL wrapper for all underlying HTTP
|
||||||
|
@ -186,7 +187,7 @@ class SoapClient extends \SoapClient
|
||||||
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
|
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
|
||||||
{
|
{
|
||||||
// wrap request data in SoapRequest object
|
// wrap request data in SoapRequest object
|
||||||
$soapRequest = SoapRequest::create($request, $location, $action, $version);
|
$soapRequest = SoapRequestFactory::create($location, $action, $version, $request);
|
||||||
|
|
||||||
// do actual SOAP request
|
// do actual SOAP request
|
||||||
$soapResponse = $this->__doRequest2($soapRequest);
|
$soapResponse = $this->__doRequest2($soapRequest);
|
||||||
|
|
|
@ -1,47 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the BeSimpleSoapCommon.
|
|
||||||
*
|
|
||||||
* (c) Christian Kerl <christian-kerl@web.de>
|
|
||||||
* (c) Francis Besset <francis.besset@gmail.com>
|
|
||||||
* (c) Andreas Schamberger <mail@andreass.net>
|
|
||||||
*
|
|
||||||
* This source file is subject to the MIT license that is bundled
|
|
||||||
* with this source code in the file LICENSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace BeSimple\SoapCommon;
|
namespace BeSimple\SoapCommon;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SOAP request message.
|
|
||||||
*
|
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
|
||||||
*/
|
|
||||||
class SoapRequest extends SoapMessage
|
class SoapRequest extends SoapMessage
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Factory function for SoapRequest.
|
|
||||||
*
|
|
||||||
* @param string $content Content
|
|
||||||
* @param string $location Location
|
|
||||||
* @param string $action SOAP action
|
|
||||||
* @param string $version SOAP version
|
|
||||||
*
|
|
||||||
* @return SoapRequest
|
|
||||||
*/
|
|
||||||
public static function create($content, $location, $action, $version)
|
|
||||||
{
|
|
||||||
$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->setVersion($version);
|
|
||||||
$contentType = SoapMessage::getContentTypeForVersion($version);
|
|
||||||
$request->setContentType($contentType);
|
|
||||||
|
|
||||||
return $request;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeSimple\SoapCommon;
|
||||||
|
|
||||||
|
class SoapRequestFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Factory function for SoapRequest.
|
||||||
|
*
|
||||||
|
* @param string $location Location
|
||||||
|
* @param string $action SOAP action
|
||||||
|
* @param string $version SOAP version
|
||||||
|
* @param string $content Content
|
||||||
|
*
|
||||||
|
* @return SoapRequest
|
||||||
|
*/
|
||||||
|
public static function create($location, $action, $version, $content = null)
|
||||||
|
{
|
||||||
|
$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->setVersion($version);
|
||||||
|
$contentType = SoapMessage::getContentTypeForVersion($version);
|
||||||
|
$request->setContentType($contentType);
|
||||||
|
|
||||||
|
return $request;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,72 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the BeSimpleSoapClient.
|
|
||||||
*
|
|
||||||
* (c) Christian Kerl <christian-kerl@web.de>
|
|
||||||
* (c) Francis Besset <francis.besset@gmail.com>
|
|
||||||
*
|
|
||||||
* This source file is subject to the MIT license that is bundled
|
|
||||||
* with this source code in the file LICENSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace BeSimple\SoapServer;
|
|
||||||
|
|
||||||
use BeSimple\SoapCommon\SoapMessage;
|
|
||||||
use BeSimple\SoapCommon\SoapRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SoapRequest class for SoapClient. Provides factory function for request object.
|
|
||||||
*
|
|
||||||
* @author Andreas Schamberger <mail@andreass.net>
|
|
||||||
*/
|
|
||||||
class SoapRequestFactory extends SoapRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Factory function for SoapRequest.
|
|
||||||
*
|
|
||||||
* @param string $content Content
|
|
||||||
* @param string $version SOAP version
|
|
||||||
*
|
|
||||||
* @return SoapRequest
|
|
||||||
*/
|
|
||||||
public static function create($content, $version)
|
|
||||||
{
|
|
||||||
$request = new SoapRequest();
|
|
||||||
|
|
||||||
// $content is if unmodified from SoapClient not a php string type!
|
|
||||||
$request->setContent($content);
|
|
||||||
$request->setLocation(self::getCurrentUrl());
|
|
||||||
$request->setAction(isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null);
|
|
||||||
$request->setVersion($version);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the current URL from the $_SERVER array.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getCurrentUrl()
|
|
||||||
{
|
|
||||||
$url = '';
|
|
||||||
if (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) === 'on' || $_SERVER['HTTPS'] === '1')) {
|
|
||||||
$url .= 'https://';
|
|
||||||
} else {
|
|
||||||
$url .= 'http://';
|
|
||||||
}
|
|
||||||
$url .= isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : '';
|
|
||||||
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
|
|
||||||
$url .= ":{$_SERVER['SERVER_PORT']}";
|
|
||||||
}
|
|
||||||
$url .= isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,8 +12,10 @@
|
||||||
|
|
||||||
namespace BeSimple\SoapServer;
|
namespace BeSimple\SoapServer;
|
||||||
|
|
||||||
|
use BeSimple\SoapCommon\SoapMessage;
|
||||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||||
use BeSimple\SoapCommon\SoapRequest;
|
use BeSimple\SoapCommon\SoapRequest;
|
||||||
|
use BeSimple\SoapCommon\SoapRequestFactory;
|
||||||
use BeSimple\SoapServer\SoapOptions\SoapServerOptions;
|
use BeSimple\SoapServer\SoapOptions\SoapServerOptions;
|
||||||
use BeSimple\SoapCommon\Converter\MtomTypeConverter;
|
use BeSimple\SoapCommon\Converter\MtomTypeConverter;
|
||||||
use BeSimple\SoapCommon\Converter\SwaTypeConverter;
|
use BeSimple\SoapCommon\Converter\SwaTypeConverter;
|
||||||
|
@ -57,12 +59,19 @@ class SoapServer extends \SoapServer
|
||||||
/**
|
/**
|
||||||
* Custom handle method to be able to modify the SOAP messages.
|
* Custom handle method to be able to modify the SOAP messages.
|
||||||
*
|
*
|
||||||
* @param string $request Request string
|
* @param string $requestUrl
|
||||||
|
* @param string $soapAction
|
||||||
|
* @param string $requestContent = null
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function handle($request = null)
|
public function handle($requestUrl, $soapAction, $requestContent = null)
|
||||||
{
|
{
|
||||||
$soapRequest = SoapRequestFactory::create($request, $this->soapVersion);
|
$soapRequest = SoapRequestFactory::create(
|
||||||
|
$requestUrl,
|
||||||
|
$soapAction,
|
||||||
|
$this->soapVersion,
|
||||||
|
$requestContent
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$soapResponse = $this->handleSoapRequest($soapRequest);
|
$soapResponse = $this->handleSoapRequest($soapRequest);
|
||||||
|
|
Loading…
Reference in New Issue