How to perform SOAP request with and without proxy

0

Good afternoon guys,

Scenery :

"The company where I work has a proxy, but sometimes you have to disable it and configure the IPv4 settings manually."

So I can consume SoapClient for the first situation with the following parameters:

$comProxy = array(
    'soap_version' => SOAP_1_2,
    'login'        => $user,
    'password'     => $pass,
    'proxy_host'     => \Config::$hostProxy,
    'proxy_port'     => \Config::$portProxy,
    'proxy_login'    => \Config::$userProxy,
    'proxy_password' => \Config::$passProxy
);

In the second situation, the following parameters are sufficient:

$semProxy = array(
    'soap_version' => SOAP_1_2,
    'login'        => $user,
    'password'     => $pass
);

Problem :

Every time you need to configure the IP settings manually, I have to manually change the parameters so that the request is successful.

The following error is caused when I manually configure the IP settings using the $ comProxy array parameters:

  

Message: SOAP-ERROR: WSDL Parsing: Could not load from   ' link ': failed to   load external entity   " link "

Attempt :

Using a custom error handler, for when SoapClient throws the cited exception (SOAP-ERROR), try to make a new request with the parameters of the $ semProxy array. But without success, because I lose the context of the execution, in addition to forcing the interruption of the script.

Question :

What do I do to make SoapClient recognize the proxy settings and use the correct parameters for each situation?

    
asked by anonymous 28.11.2018 / 18:58

0 answers