@@ -47,24 +47,26 @@ class Client extends \Soapclient
47
47
* @param bool $cache
48
48
* @param bool $debug
49
49
* @param bool $test
50
+ * @param bool $sslCheck
50
51
*/
51
52
public function __construct (
52
53
string $ login ,
53
54
string $ password ,
54
55
bool $ cache = false ,
55
56
bool $ debug = false ,
56
- bool $ test = false
57
+ bool $ test = false ,
58
+ bool $ sslCheck = true
57
59
) {
58
- $ this ->login = $ login ;
60
+ $ this ->login = $ login ;
59
61
$ this ->password = $ password ;
60
- $ this ->debug = $ debug ;
61
-
62
- parent :: __construct ( $ test ? static :: TEST_WSDL : static :: PROD_WSDL , [
63
- 'cache_wsdl ' => $ cache ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE ,
64
- 'trace ' => $ debug ? 1 : 0 ,
65
- 'soap_version ' => SOAP_1_2 ,
66
- 'compression ' => true ,
67
- 'classmap ' => [
62
+ $ this ->debug = $ debug ;
63
+
64
+ $ options = [
65
+ 'cache_wsdl ' => $ cache ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE ,
66
+ 'trace ' => $ debug ? 1 : 0 ,
67
+ 'soap_version ' => SOAP_1_2 ,
68
+ 'compression ' => true ,
69
+ 'classmap ' => [
68
70
'Address ' => Model \Address::class,
69
71
'ArrayOfLabel ' => Model \ArrayOfLabel::class,
70
72
'ArrayOfShipment ' => Model \ArrayOfShipment::class,
@@ -86,7 +88,19 @@ public function __construct(
86
88
'GetLabelResponse ' => Response \GetLabelResponse::class,
87
89
'GetShipmentResponse ' => Response \GetShipmentResponse::class,
88
90
],
89
- ]);
91
+ ];
92
+
93
+ if (!$ sslCheck ) {
94
+ $ options ['stream_context ' ] = stream_context_create ([
95
+ 'ssl ' => [
96
+ 'verify_peer ' => false ,
97
+ 'verify_peer_name ' => false ,
98
+ 'allow_self_signed ' => true ,
99
+ ],
100
+ ]);
101
+ }
102
+
103
+ parent ::__construct ($ test ? static ::TEST_WSDL : static ::PROD_WSDL , $ options );
90
104
}
91
105
92
106
/**
@@ -106,7 +120,7 @@ public function call(string $method, array $arguments): ResponseInterface
106
120
$ exception = new ClientException ($ e ->getMessage (), $ e ->getCode (), $ e );
107
121
108
122
if ($ this ->debug ) {
109
- $ exception ->request = ClientException::formatXml ($ this ->__getLastRequest ());
123
+ $ exception ->request = ClientException::formatXml ($ this ->__getLastRequest ());
110
124
$ exception ->response = ClientException::formatXml ($ this ->__getLastResponse ());
111
125
}
112
126
0 commit comments