I got a cPanel hosting with Dedicated IP address,
the outgoing IP however is still the shared IP of the host provider (which should be).
I need to do some outgoing calls using nusoap with that Dedicated IP:
$nusoap = new nusoap_client("https://URL/");
$call = $nusoap->call(...);
How can I change the outgoing IP here with NuSOAP?
I know how to do it with cURL (curl_setopt($ch, CURLOPT_INTERFACE, $website_ip);
), but how to achieve same thing with this method. been working on it for hours now, server side and php side but still couldn't figure it out.
1) Use PHP's SoapClient
and not NuSoap (it's been available since PHP5, and hopefully you're not still using PHP4 as it's very out-of-support and the NuSoap library itself has not been updated for over 3 years).
2) You can pass a stream context to your SoapClient constructor that has a bindto
options set.
Credits: Taken straight from Is it possible to specify the outgoing network interface to use for a PHP SoapClient?
$opts = array(
'socket' => array(
'bindto' => '192.168.0.100:0',
),
);
$ctx = stream_context_create($opts);
$client = new SoapClient('the.wsdl', array('stream_context' => $ctx));
Edit: If you must use NuSoap, have you tried
nusoap_client->setCurlOption(CURLOPT_INTERFACE, $website_ip)
From the source:
function setCurlOption($option, $value) {
$this->debug("setCurlOption option=$option, value=");
$this->appendDebug($this->varDump($value));
$this->curl_options[$option] = $value;
}