moved code to common

This commit is contained in:
Andreas Schamberger
2012-01-07 13:18:52 +01:00
parent daadd04657
commit 4d05f2889f
7 changed files with 3 additions and 541 deletions

View File

@ -25,13 +25,6 @@ use BeSimple\SoapCommon\SoapKernel;
*/
class SoapClient extends \SoapClient
{
/**
* SOAP attachment type.
*
* @var int
*/
protected $attachmentType = Helper::ATTACHMENTS_TYPE_BASE64;
/**
* Soap version.
*
@ -104,16 +97,12 @@ class SoapClient extends \SoapClient
if (isset($options['soap_version'])) {
$this->soapVersion = $options['soap_version'];
}
// attachment handling
if (isset($options['attachment_type'])) {
$this->attachmentType = $options['attachment_type'];
}
$this->curl = new Curl($options);
$wsdlFile = $this->loadWsdl($wsdl, $options);
// TODO $wsdlHandler = new WsdlHandler($wsdlFile, $this->soapVersion);
$this->soapKernel = new SoapKernel();
// set up type converter and mime filter
$this->configureMime($options);
$this->soapKernel->configureMime($options);
// we want the exceptions option to be set
$options['exceptions'] = true;
// disable obsolete trace option for native SoapClient as we need to do our own tracing anyways
@ -258,43 +247,6 @@ class SoapClient extends \SoapClient
return $this->lastResponse;
}
/**
* Configure filter and type converter for SwA/MTOM.
*
* @param array &$options SOAP constructor options array.
*
* @return void
*/
private function configureMime(array &$options)
{
if (Helper::ATTACHMENTS_TYPE_BASE64 !== $this->attachmentType) {
// register mime filter in SoapKernel
$mimeFilter = new MimeFilter($this->attachmentType);
$this->soapKernel->registerFilter($mimeFilter);
// configure type converter
if (Helper::ATTACHMENTS_TYPE_SWA === $this->attachmentType) {
$converter = new SwaTypeConverter();
} elseif (Helper::ATTACHMENTS_TYPE_MTOM === $this->attachmentType) {
$converter = new MtomTypeConverter();
}
// configure typemap
if (!isset($options['typemap'])) {
$options['typemap'] = array();
}
$soapKernel = $this->soapKernel;
$options['typemap'][] = array(
'type_name' => $converter->getTypeName(),
'type_ns' => $converter->getTypeNamespace(),
'from_xml' => function($input) use ($converter, $soapKernel) {
return $converter->convertXmlToPhp($input, $soapKernel);
},
'to_xml' => function($input) use ($converter, $soapKernel) {
return $converter->convertPhpToXml($input, $soapKernel);
},
);
}
}
/**
* Get SoapKernel instance.
*