2016-12-16 5 views
16

プロキシの背後にPHP SoapClientとSoapServer(Magento用)の両方を実行しようとしています。このように、クライアントでの作業プロキシの背後でPHP SoapServerを実行しています

私が持っている:

$client = new SoapClient('https://www.domain.co.uk/api/v2_soap/?wsdl=1', [ 
    'soap_version' => SOAP_1_1, 
    'connection_timeout' => 15000, 
    'proxy_host' => '192.168.x.x', 
    'proxy_port' => 'xxxx', 
    'stream_context' => stream_context_create(
     [ 
      'ssl' => [ 
       'proxy' => 'tcp://192.168.x.x:xxxx', 
       'request_fulluri' => true, 
      ], 
      'http' => [ 
       'proxy' => 'tcp://192.168.x.x:xxxx', 
       'request_fulluri' => true, 
      ], 
     ] 
    ), 
]); 

この期待通りに動作します - すべてのトラフィックがプロキシサーバーを経由して起こっています。

しかし、SoapServerクラスでは、SoapServer経由ですべての送信トラフィックを送信するように強制する方法はありません。 "http://schemas.xmlsoap.org/soap/encoding/ 'スキーマをインポートできません"というエラーがスローされる原因となっているプロキシ経由ではなく、http://schemas.xmlsoap.org/soap/encoding/を直接ネットワークからロードしようとしています。

私はschemas.xmlsoap.orgのホストファイルエントリを127.0.0.1に追加してこのファイルをローカルにホスティングしようとしましたが、私はまだ同じ問題を抱えています。

紛失しているものがありますか? file_get_contentsのよう

答えて

3

するTry stream_context_set_default: file_get_contents behind a proxy?

<?php 
// Edit the four values below 
$PROXY_HOST = "proxy.example.com"; // Proxy server address 
$PROXY_PORT = "1234"; // Proxy server port 
$PROXY_USER = "LOGIN"; // Username 
$PROXY_PASS = "PASSWORD"; // Password 
// Username and Password are required only if your proxy server needs basic authentication 

$auth = base64_encode("$PROXY_USER:$PROXY_PASS"); 
stream_context_set_default(
array(
    'http' => array(
    'proxy' => "tcp://$PROXY_HOST:$PROXY_PORT", 
    'request_fulluri' => true, 
    'header' => "Proxy-Authorization: Basic $auth" 
    // Remove the 'header' option if proxy authentication is not required 
) 
) 
); 
//Your SoapServer here 

または非WSDLモードで

<?php 
$server = new SoapServer(null, array('uri' => "http://localhost/namespace")); 
$server->setClass('myClass'); 
$data = file_get_contents('php://input'); 
$server->handle($data); 
をサーバーを実行しよう
関連する問題