14
14
class SoapClientFactory
15
15
{
16
16
const WEB_SERVICE_CHARSET = 'ISO-8859-1 ' ;
17
+ const WEB_SERVICE_LR_CHARSET = 'UTF-8 ' ;
17
18
18
19
const SOAP_VERSION = 'SOAP_1_1 ' ;
19
20
@@ -35,6 +36,11 @@ class SoapClientFactory
35
36
* @var \SoapClient
36
37
*/
37
38
protected static $ _soapAgenciaWS ;
39
+
40
+ /**
41
+ * @var \SoapClient
42
+ */
43
+ protected static $ _soapLogisticaReversa ;
38
44
39
45
/**
40
46
*
@@ -277,6 +283,49 @@ public static function getSoapPI()
277
283
return self ::$ _soapClient ;
278
284
}
279
285
286
+ /**
287
+ *
288
+ * @return \SoapClient
289
+ * @throws tSoapLogisticaReversa
290
+ */
291
+
292
+ public static function getSoapLogisticaReversa ()
293
+ {
294
+ if (!self ::$ _soapLogisticaReversa ) {
295
+ $ wsdl = Bootstrap::getConfig ()->getWsdlLogisticaReversa ();
296
+
297
+ $ opts = array (
298
+ 'ssl ' => array ( //'ciphers' =>'RC4-SHA',
299
+ 'verify_peer ' =>false ,
300
+ 'verify_peer_name ' =>false
301
+ )
302
+ );
303
+ // SOAP 1.1 client
304
+
305
+
306
+ $ params = array (
307
+ 'encoding ' => self ::WEB_SERVICE_LR_CHARSET ,
308
+ 'verifypeer ' => false ,
309
+ 'verifyhost ' => false ,
310
+ 'uri ' => str_replace ('?wsdl ' , '' , $ wsdl ),
311
+ 'soap_version ' => SOAP_1_1 ,
312
+ // 'cache_wsdl' => WSDL_CACHE_DISK,
313
+ 'trace ' => Bootstrap::getConfig ()->getEnv () != Config::ENV_PRODUCTION ,
314
+ 'exceptions ' => Bootstrap::getConfig ()->getEnv () != Config::ENV_PRODUCTION ,
315
+ "connection_timeout " => 60 ,//($wsdl->timeout ?: 60),
316
+ 'stream_context ' => stream_context_create ($ opts ),
317
+ //usuário e senha, necessários para autenticação
318
+ 'login ' => Bootstrap::getConfig ()->getAccessData ()->getIdCorreiosUsuario (),
319
+ 'password ' => Bootstrap::getConfig ()->getAccessData ()->getIdCorreiosSenha (),
320
+ );
321
+
322
+ self ::$ _soapLogisticaReversa = new \SoapClient ($ wsdl , $ params );
323
+ }
324
+
325
+ return self ::$ _soapLogisticaReversa ;
326
+ }
327
+
328
+
280
329
/**
281
330
* Se possível converte a string recebida.
282
331
* @param $string
@@ -301,8 +350,5 @@ public static function convertEncoding($string)
301
350
return $ str ;
302
351
}
303
352
304
- public static function setSoapClient (?\SoapClient $ client ): void
305
- {
306
- self ::$ _soapClient = $ client ;
307
- }
308
353
}
354
+
0 commit comments