2012-12-13 173 views
0

無法爲我的生活獲取此SOAP客戶端的工作。在我的朋友框中正常工作,並且我比較了php.ini,並且看不到與SOAP設置有關的任何內容。我正在運行最新的PHP和UBuntu 12.10。PHP SOAP客戶端。 HTTPS無法連接

這裏是我的代碼:

$url = "https://m2mconnect.orange.co.uk/orange-soap/services/MessageServiceByCountry?wsdl"; 
$options["connection_timeout"] = 1000; 
$options["location"] = $url; 
$options['trace'] = 1; 


try { 
$client = new SoapClient("orange.xml",$options); 

print_r($client->__getFunctions()); 



$client->peekMessages(
    'user', 
    'pass', 
    10 
); 

var_dump($client); 
} catch (Exception $e) { 
    echo "REQUEST:\n" . $client->__getLastRequest() . "\n"; 
    echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n"; 
    echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "\n"; 
    echo "Response:\n" . $client->__getLastResponse() . "\n"; 
    echo "Exception: \n" . $e->getMessage() . "\n"; 
    echo "Trace: \n" . $e->getTraceAsString() . "\n"; 
} 

我不得不把WSDL保存爲一個文件,否則我收到一個不同的錯誤!

下面是代碼運行:

Array 
(
    [0] => int sendMessage(string $username, string $password, string $deviceMSISDN, string $message, boolean $deliveryReport, string $mtBearer) 
    [1] => ArrayOf_xsd_string getDeliveryReports(string $username, string $password, string $deviceMSISDN, string $countryCode) 
    [2] => ArrayOf_xsd_string readMessages(string $username, string $password, int $count, string $deviceMsisdn, string $countryCode) 
    [3] => boolean flushMessages(string $username, string $password, string $deviceMSISDN, string $countryCode) 
    [4] => ArrayOf_xsd_string waitForMessage(string $username, string $password, int $timeout, string $deviceMSISDN, int $msgref, string $countryCode) 
    [5] => int sendMessageWithValidityPeriod(string $username, string $password, string $deviceMSISDN, string $message, boolean $deliveryReport, string $mtBearer, string $binarySmsDcs, string $validityDaysHoursMins) 
    [6] => int sendBinarySmsMessage(string $username, string $password, string $deviceMSISDN, string $message, boolean $deliveryReport, string $mtBearer, string $binarySmsDcs) 
    [7] => ArrayOf_xsd_string sendAndWait(string $username, string $password, int $timeout, string $deviceMSISDN, string $message, boolean $deliveryReport, string $mtBearer) 
    [8] => ArrayOf_xsd_string sendBinarySmsAndWait(string $username, string $password, int $timeout, string $deviceMSISDN, string $message, boolean $deliveryReport, string $mtBearer, string $binarySmsDcs) 
    [9] => ArrayOf_xsd_string peekMessages(string $username, string $password, int $count, string $deviceMsisdn, string $countryCode) 
    [10] => ArrayOf_xsd_string getDeliveryReportsFromDate(string $username, string $password, string $deviceMSISDN, string $countryCode, string $fromDate) 
) 
REQUEST: 
<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soap.otel.telematics.orange.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:peekMessages><username xsi:type="xsd:string">username</username><password xsi:type="xsd:string">password</password><count xsi:type="xsd:int">10</count><deviceMsisdn xsi:nil="true"/><countryCode xsi:nil="true"/></ns1:peekMessages></SOAP-ENV:Body></SOAP-ENV:Envelope> 

REQUEST HEADERS: 

RESPONSE HEADERS: 

RESPONSE: 

EXCEPTION: 
Could not connect to host 
Trace: 
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://m2mconn...', '', 1, 0) 
#1 /var/www/soap-app.com/Zend/public/soap.php(34): SoapClient->__call('peekMessages', Array) 
#2 /var/www/soap-app.com/Zend/public/soap.php(34): SoapClient->peekMessages('username', 'password', 10) 
#3 {main} 

我的用戶名&密碼是否正確。我相信這與SSL有關。這裏是我的SOAP和SSL php.ini設置:

soap 
Soap Client  enabled 
Soap Server  enabled 

Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, tls 

curl SSL  Yes 

openssl 
OpenSSL support    enabled 
OpenSSL Library Version  OpenSSL 1.0.1c 10 May 2012 
OpenSSL Header Version  OpenSSL 1.0.1c 10 May 2012 
SSL Version     OpenSSL/1.0.1c 

任何幫助將是偉大的。把我的頭髮拉出來!

更多細節:

運行:

echo file_get_contents('https://m2mconnect.orange.co.uk/orange-soap/services/Message‌​ServiceByCountry?wsdl'); 

結果:

Warning: file_get_contents(): Failed to enable crypto. 

編輯:

似乎這些錯誤門票相關: https://bugs.php.net/bug.php?id=52106

但是我使用最新的PHP版本,我需要爲我使用Zend框架2.

+0

(1)是'allow_url_fopen = 1'? (2)你可以'file_get_contents('https://m2mconnect.orange.co.uk/orange-soap/services/MessageServiceByCountry?wsdl');'? – Wrikken

+0

*無法連接到主機* < - 連接問題。檢查您的網絡設置。並且不要把所有的頭髮都拉出來;) – hakre

+0

我的網絡連接沒有問題,因爲我可以通過瀏覽器瀏覽網站。 allow_url_fopen是1. –

回答

0

看來這一切都是因爲我的網絡設置。我正在使用安裝了開源固件DD-WRT的路由器來擴展我的無線網絡。當我將該路由器從網絡中取出時,連接成功。花了一個星期解決這個問題!

0

https://m2mconnect.orange.co.uk/orange-soap/services/MessageServiceByCountry?wsdl

不會出現加載,相同的只有HTTP://

如果你說你可以得到它,那麼這不應該是一個問題。但是,如果您需要更多幫助,那麼我建議您將其設置爲可以訪問該URL。然後我們可以給它適當的測試和更好的解決方案。

+0

您可以連接嗎?我無法解決此問題 –

+0

顯示您的鏈接仍然無法正常工作。確保你現在沒有任何防火牆阻止我們看到它。 – Diemuzi

+0

什麼?它適用於我嘗試過的大約4種不同的設備。這不是我的服務器。它是橙色的。正如Orange在電信網絡中一樣! –