【发布时间】:2011-04-15 06:41:55
【问题描述】:
我需要实现一个网络服务,其中SoapServer 要求我使用SoapClient 机器上的特定IP 发送数据,该机器有一堆不同的IP。问题是,如何强制 PHP 使用这个特定的 IP 发送该请求?
关于 SOAP 的 PHP 文档真的很差。
谢谢。
通过 halfdan 的回答,我能够解决这个问题,所以我发布了一个关于结果如何的 sn-p:
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");
}
}
}
【问题讨论】:
标签: php soap soap-client