我需要實現一個web服務,其中SoapServer
要求我在SoapClient
機器上使用特定IP發送數據,這些機器上有許多不同的IP。問題是,如何強制PHP使用此特定IP發送該請求?將SoapClient請求綁定到特定的IP
有關SOAP的PHP文檔非常差。
謝謝。
隨着哈夫丹的回答我能解決這個問題,所以我張貼的是如何變成了一個片段:
protected function load_ws() {
if ($this->ws == null) { // load webservice
ini_set("soap.wsdl_cache_enabled", 0);
ini_set("allow_url_fopen", 1);
try {
if ($this->context == null) // load stream context socket
$this->context = stream_context_create(array(
"socket" => array(
"bindto" => te_auth_ip.":0"
)
));
$this->ws = new SoapClient($this->wsdl_path, array(
"soap_version" => SOAP_1_1,
"style" => SOAP_RPC,
"use" => SOAP_ENCODED,
"authentication" => SOAP_AUTHENTICATION_BASIC,
"login" => te_login,
"password" => te_pass,
"encoding" => "UTF-8",
"trace" => true,
"exceptions" => true,
"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
"connection_timeout" => te_timeout,
"stream_context" => $this->context
));
} catch (SoapFault $fault) {
$this->error($fault, "LOAD");
}
}
}
我的建議工作? – halfdan 2010-09-21 16:36:30