我一辈子都无法让这个 SOAP 客户端正常工作。在我的朋友框上工作正常,我比较了 php.ini,看不到任何与 SOAP 设置相关的内容。我正在运行最新的 PHP 和 UBuntu 12.10。
这是我的代码:
$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/MessageServiceByCountry?wsdl');
结果是:
Warning: file_get_contents(): Failed to enable crypto.
编辑:
似乎这些错误票是相关的: https ://bugs.php.net/bug.php?id=52106
但是我使用的是最新的 PHP 版本,我需要使用 Zend Framework 2。