From 3d906dc97a7e3e4002f5123f6bc875901afec7d3 Mon Sep 17 00:00:00 2001 From: Andreas Schamberger Date: Tue, 1 Nov 2011 17:17:16 +0100 Subject: [PATCH] load WSDL file into DOM only if necessary --- src/BeSimple/SoapCommon/WsdlHandler.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/BeSimple/SoapCommon/WsdlHandler.php b/src/BeSimple/SoapCommon/WsdlHandler.php index cec21f5..28ab5b5 100644 --- a/src/BeSimple/SoapCommon/WsdlHandler.php +++ b/src/BeSimple/SoapCommon/WsdlHandler.php @@ -99,12 +99,6 @@ class WsdlHandler } else { $this->wsdlSoapNamespace = self::NS_WSDL_SOAP_1_2; } - $this->domDocument = new \DOMDocument('1.0', 'utf-8'); - $this->domDocument->load($this->wsdlFile); - $this->domXpath = new \DOMXPath($this->domDocument); - $this->domXpath->registerNamespace('wsdl', self::NS_WSDL); - $this->domXpath->registerNamespace('mime', self::NS_WSDL_MIME); - $this->domXpath->registerNamespace('soap', $this->wsdlSoapNamespace); } /** @@ -179,6 +173,8 @@ class WsdlHandler */ public function isValidMimeTypeType($soapAction, $operationType, $part, $currentMimeType) { + // create DOMDocument from WSDL file + $this->loadWsdlInDom(); // load data from WSDL if (!isset($this->mimeTypes[$soapAction])) { $this->mimeTypes[$soapAction] = $this->getMimeTypesForSoapAction($soapAction); @@ -203,4 +199,21 @@ class WsdlHandler } return false; } + + /** + * Loads the WSDL file into a DOM + * + * @return void + */ + private function loadWsdlInDom() + { + if (is_null($this->domDocument)) { + $this->domDocument = new \DOMDocument('1.0', 'utf-8'); + $this->domDocument->load($this->wsdlFile); + $this->domXpath = new \DOMXPath($this->domDocument); + $this->domXpath->registerNamespace('wsdl', self::NS_WSDL); + $this->domXpath->registerNamespace('mime', self::NS_WSDL_MIME); + $this->domXpath->registerNamespace('soap', $this->wsdlSoapNamespace); + } + } } \ No newline at end of file