1

さまざまな IP が多数あるマシンでSoapServer特定の IP を使用してデータを送信する必要がある Web サービスを実装する必要があります。SoapClient問題は、この特定の IP を使用して PHP にそのリクエストを送信させる方法です。

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");
        }

    }
}
4

1 に答える 1

4

これは機能するはずです ( #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));

ドキュメントにこのオプションを含めることに同意します。

于 2010-09-21T15:49:00.690 に答える