I am using soap client to connect to a wsdl service. the soap client use a custom authentication mode which I am adding them to http by following code
$client=new SoapClient(
$wsdl,
array(
'trace' => 1,
"stream_context" => stream_context_create(
array(
"http"=>array(
"header"=> "username: xmluatbank\r\n".
"password: 123456\r\n"
)
)
)
);
and the header came as follow.
POST /myweb/Proxy HTTP/1.1
Host: uat.myweb.com:8080
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.19
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 1086
username: xmluatbank
password: 123456
so far until here everything was fine, then came new request to need to connect through proxy, so I changed the code to follwing:
$client=new SoapClient(
$wsdl,
array(
'trace' => 1,
"stream_context" => stream_context_create(
array(
"http"=>array(
"header"=> "username: xmluatbank\r\n".
"password: 123456\r\n"
)
),
'proxy_host' => $proxy,
'proxy_port' => $proxyport,
'proxy_login' => $proxyusrname,
'proxy_password' => $proxypwd,
)
);
and the header became like this:
POST http://uat.myweb.com:8080/ctos/Proxy HTTP/1.1
Host: uat.myweb.com:8080
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.9-ZS5.6.0
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 1086
Proxy-Authorization: Basic YWdyb2JhbmtcanVyaXMudnRjbDpBYmNkMTIx==
as you can see the stream context that I had now is gone,so now I am getting the authentication error with the wsdl server. look like proxy overwrite the the http header. so I tried to add the proxy to http header and not use the soap proxy
$sLogin = base64_encode("$proxyusername:$proxypwd");
$aHTTP['http']['proxy'] = "$proxy:$proxyprot";
$aHTTP['http']['method'] = 'POST';
$aHTTP['http']['header'] = "User-Agent: My PHP Script\r\n";
$aHTTP['http']['header'] .= "Proxy-Authorization: Basic $sLogin";
$aHTTP['http']['header'] .= "username: xmluatbank\r\n"."password: 1234567\r\n";
$context = stream_context_create($aHTTP);
and called the soap client like this :
$client=new SoapClient(
$wsdl,
array(
'trace' => 1,
"stream_context" => $context
)
);
but this way I am getting soap error and cannot connect to proxy.
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://uat.myweb.com:8080/ctos/Proxy?wsdl' : failed to load external entity "http://uat.myweb.com:8080/myweb/Proxy?wsdl"
I am out of idea how to solve this. I tried all that I knew, please help