Мне нужно вызвать SOAP WS на сервере .Net, используя (из документации моего клиента)
SOAP 1.1
WS-Addressing (August 2004)
WS-Security 1.1
WS-Trust (February 2005)
WS-SecureConversation (February 2005)
WS-SecurityPolicy 1.1
Я использую WSO2 WSF/PHP (файл wso2-wsf-php-src-2.1.0.zip), вот мой клиент
function appel($rec_cert, $pvt_key, $sUrl)
{
$reqPayloadString = <<<XML
<ns1:echo xmlns:ns1="http://wso2.org/wsfphp/samples"><text>Hello World!</text></ns1:echo>
XML;
$sPolicy = dirname(__FILE__) . '/policy.xml';
$sAction = "http://www.aaa.fr/SendMessage";
$reqMessage = new WSMessage($reqPayloadString, array("to" => $sUrl, "action" => $sAction));
$policy_xml = file_get_contents($sPolicy);
$policy = new WSPolicy($policy_xml);
$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, "receiverCertificate" => $rec_cert));
$client = new WSClient(array(
"useSOAP"=>1.1,
"useWSA" => 1.0,
"policy" => $policy,
"securityToken" => $sec_token,
));
$resMessage = $client->request($reqMessage);
printf("Response = %s \n", $resMessage->str);
}
В моем локальном веб-сервисе он работает нормально, но просто выдает исключение «Ошибка, ответ не получен» на моем предварительном сервере клиента. Я просто не использую те же ключи и сертификаты, так как у меня нет секретного ключа клиента.
Вот мой локальный веб-сервис
<?php
function echoFunction($inMessage) {
$returnMessage = new WSMessage($inMessage->str);
return $returnMessage;
}
$pub_key = ws_get_cert_from_file("/var/www/samples/security/keys/alice_cert.cert");
$pvt_key = ws_get_key_from_file("/var/www/samples/security/keys/bob_key.pem");
$operations = array("echoString" => "echoFunction");
$actions = array("http://www.aaa.fr/SendMessage" => "echoString");
$policy = new WSPolicy(file_get_contents("policy.xml"));
$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, "receiverCertificate" => $pub_key));
$svr = new WSService(array(
"actions" => $actions,
"operations" => $operations,
"policy" => $policy,
"securityToken" => $sec_token));
$svr->reply();
Большая проблема заключается в том, что эта ошибка произошла из-за несуществующего URL-адреса, другой политики между клиентом и сервером и нескольких других ошибок, которые я могу создать на своем сервере.
Есть первое свидетельство из wsf_php_client.log:
[Mon Jan 28 15:49:02 2013] [error] assertion_builder.c(510) [neethi] Unknown Assertion RampartConfig with namespace http://ws1.apache.org/rampart/policy
[Mon Jan 28 15:49:02 2013] [error] engine.c(548) [neethi] Assertion creation failed from element.
[Mon Jan 28 15:49:02 2013] [error] engine.c(145) [neethi] All creation failed
[Mon Jan 28 15:49:02 2013] [error] engine.c(473) [neethi] All creation failed from element.
[Mon Jan 28 15:49:02 2013] [error] engine.c(190) [neethi] Exactlyone creation failed.
[Mon Jan 28 15:49:02 2013] [error] engine.c(496) [neethi] Exactlyone creation failed from element.
[Mon Jan 28 15:49:02 2013] [error] engine.c(285) [neethi] Policy creation failed.
и второй (я ищу об этом)
[Mon Jan 28 16:18:13 2013] [info] Starting addressing out handler
[Mon Jan 28 16:18:13 2013] [debug] http_transport_sender.c(241) ctx_epr:https://recette.customer.fr/securit.svc
[Mon Jan 28 16:18:13 2013] [debug] http_transport_sender.c(776) using axis2 native http sender.
[Mon Jan 28 16:18:13 2013] [debug] http_sender.c(494) msg_ctx_id:urn:uuid:ef0a33e6-695d-1e21-2453-d43d7e273c95
[Mon Jan 28 16:18:13 2013] [debug] http_transport_utils.c(3794) No session map stored
[Mon Jan 28 16:18:13 2013] [info] [ssl client] CA certificate not specified
[Mon Jan 28 16:18:13 2013] [error] ssl/ssl_utils.c(50) Cannot find certificates
[Mon Jan 28 16:18:13 2013] [error] ssl/ssl_stream.c(99) Error occurred in SSL engine
[Mon Jan 28 16:18:13 2013] [error] http_client.c(294) Data stream creation failed for Host recette.customer.fr and 443 port
[Mon Jan 28 16:18:13 2013] [error] http_client.c(560) Client data stream null or socket error for host recette.customer.fr and 443 port
[Mon Jan 28 16:18:13 2013] [error] http_client.c(562) A read attempt(HTTP) for the reply without sending the request
[Mon Jan 28 16:18:13 2013] [error] http_sender.c(1303) status_code < 0
[Mon Jan 28 16:18:13 2013] [error] engine.c(171) Transport sender invoke failed
[Mon Jan 28 16:18:13 2013] [error] /home/cedric/wso2-wsf-php-src-2.1.0/src/wsf_client.c(1696) [WSF/PHP] Response Payload NULL( Error number and code) => : 76 :: A read attempt(HTTP) for the reply without sending the request
Где я могу найти дополнительную информацию для решения моей проблемы? Я уже прошу клиента сказать мне, есть ли у него какие-либо следы моих звонков WS (но у меня пока нет ответа).