2016-12-16 37 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並在本地託管此文件,但我仍然遇到同樣的問題。

有什麼我失蹤了嗎?

回答

3

嘗試stream_context_set_default像的file_get_contents: 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); 
相關問題