@@ -57,6 +57,7 @@ public function setSoapClient(\SoapClient $soapClient)
5757 * @uses AbstractSoapClientBase::getDefaultWsdlOptions()
5858 * @uses AbstractSoapClientBase::getSoapClientClassName()
5959 * @uses AbstractSoapClientBase::setSoapClient()
60+ * @uses AbstractSoapClientBase::OPTION_PREFIX
6061 * @param array $options WSDL options
6162 * @return void
6263 */
@@ -71,20 +72,42 @@ public function initSoapClient(array $options)
7172 $ wsdlOptions [str_replace (self ::OPTION_PREFIX , '' , $ optionName )] = $ optionValue ;
7273 }
7374 }
74- if (array_key_exists (str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL ), $ wsdlOptions )) {
75- $ wsdlUrl = $ wsdlOptions [str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL )];
76- unset($ wsdlOptions [str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL )]);
75+ if (self ::canInstantiateSoapClientWithOptions ($ wsdlOptions )) {
76+ $ wsdlUrl = null ;
77+ if (array_key_exists (str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL ), $ wsdlOptions )) {
78+ $ wsdlUrl = $ wsdlOptions [str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL )];
79+ unset($ wsdlOptions [str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL )]);
80+ }
7781 $ soapClientClassName = $ this ->getSoapClientClassName ();
7882 $ this ->setSoapClient (new $ soapClientClassName ($ wsdlUrl , $ wsdlOptions ));
7983 }
8084 }
85+ /**
86+ * Checks if the provided options are sufficient to instantiate a SoapClient:
87+ * - WSDL-mode : only the WSDL is required
88+ * - non-WSDL-mode : URI and LOCATION are required, WSDL url can be empty then
89+ * @uses AbstractSoapClientBase::OPTION_PREFIX
90+ * @param $wsdlOptions
91+ * @return bool
92+ */
93+ protected static function canInstantiateSoapClientWithOptions ($ wsdlOptions )
94+ {
95+ return (
96+ array_key_exists (str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URL ), $ wsdlOptions ) ||
97+ (
98+ array_key_exists (str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_URI ), $ wsdlOptions ) &&
99+ array_key_exists (str_replace (self ::OPTION_PREFIX , '' , self ::WSDL_LOCATION ), $ wsdlOptions )
100+ )
101+ );
102+ }
81103 /**
82104 * Returns the SoapClient class name to use to create the instance of the SoapClient.
83105 * The SoapClient class is determined based on the package name.
84106 * If a class is named as {Api}SoapClient, then this is the class that will be used.
85107 * Be sure that this class inherits from the native PHP SoapClient class and this class has been loaded or can be loaded.
86108 * The goal is to allow the override of the SoapClient without having to modify this generated class.
87109 * Then the overridding SoapClient class can override for example the SoapClient::__doRequest() method if it is needed.
110+ * @uses AbstractSoapClientBase::DEFAULT_SOAP_CLIENT_CLASS
88111 * @return string
89112 */
90113 public function getSoapClientClassName ($ soapClientClassName = null )
0 commit comments