Rod*_*igo 1 php soap soap-client
我需要实现一个网络服务,要求我在具有一堆不同 IP 的机器SoapServer上使用特定 IP 发送数据。SoapClient问题是,如何强制 PHP 使用这个特定的 IP 发送该请求?
关于 SOAP 的 PHP 文档确实很差。
谢谢。
通过 halfdan 的回答,我能够解决这个问题,所以我发布了一个结果片段:
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");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这应该有效(参见#60004):
$options = array('socket' => array('bindto' => 'www.xxx.yyy.zzz:port'));
$context = stream_context_create($options);
$soap = new SoapClient($wsdl, array('location'=>'http://...','uri' => '...','stream_context' => $context));
Run Code Online (Sandbox Code Playgroud)
我同意文档应包含此选项。
| 归档时间: |
|
| 查看次数: |
4523 次 |
| 最近记录: |