views:

16

answers:

1

I need to bind a SoapClient to a specific outbound network interface, but I cannot find any documentation on this. Is this even possible? If not, what are some possible workarounds?

+3  A: 

You can pass a stream context to your soapclient constructor that has a bindto options set:

$opts = array(
    'socket' => array(
        'bindto' => '192.168.0.100:0',
     ),
);

$ctx = stream_context_create($opts);

$client = new SoapClient('the.wsdl', array('stream_context' => $ctx));
cythrawll
Wow, simple. Thanks!
hobodave