ネイティブ PHP SOAP 拡張機能をアクティブにして、centos サーバー (PHP 5.2.10、apache/2.2.3) に wso2 PHP WS 2.1.0 フレームワークをセットアップしました。サンプル WS クライアントは正常に動作します。私の WS インストールとデフォルトの唯一の違いは、wsf ファイルがパス構造 /var/lib/ ではなく /usr/lib64/php/modules/wsf_c/ にあることです。
次のクライアント スクリプトを使用して完全な SOAP 要求を生成する際に問題が発生しています -
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$reqPayloadString = <<<XML
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope” xmlns:typ=”http://service.dataxmldistribution.argos.cls.fr/types”>
<soap:Header/>
<soap:Body>
<typ:xmlRequest>
<typ:username>user</typ:username>
<typ:password>password</typ:password>
<typ:platformId>'1,2,3,4,5'</typ:platformId>
<typ:nbDaysFromNow>10</typ:nbDaysFromNow>
</typ:xmlRequest>
</soap:Body>
</soap:Envelope>
XML;
$reqMessage = new WSMessage($reqPayloadString);
try {
$client = new WSClient(array(
"wsdl" => "http://ws-argos.cls.fr/argosDws/services/DixService?wsdl",
"to" => "http://ws-argos.cls.fr/argosDws/services/DixService",
"useSOAP" => 1.2,
"action"=>"getXml"
));
$resMessage = $client->request($reqPayloadString);
printf("Response = %s <br/>\n", htmlspecialchars($resMessage->str));
} catch (Exception $e) {
if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->code);
} else {
printf("Message = %s\n",$e->getMessage());
}
}
printf("<br/> Request = %s </br>",
htmlspecialchars($client->getLastRequest()));
printf("<br/> Response = %s </br>",
htmlspecialchars($client->getLastResponse()));
?>
スクリプトは次を返します -
Message = Invalid Input Message
Request = <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body></soapenv:Body></soapenv:Envelope>
Response = <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:lang="en">Fault occurred while processing.</soap:Text></soap:Reason></soap:Fault></soap:Body></soap:Envelope>
クライアント ログには、「om_document.c(102) ルート ノードを取得できません」という 1 つのエラーが表示されます。
getLastRequest からのプリントアウトの body 要素内に xml リクエストが欠落しているという事実は、おそらく名前空間を使用して、ペイロード xml を別の方法でフォーマットする必要があると思いますか?
これがどのように見えるかはわかりませんので、これが問題である場合は、アドバイスをいただければ幸いです。WSClient 配列で参照される 'wsdl' を使用して、または使用せずにこの要求を試し、ペイロードを XML 文字列ではなく配列として定義しようとしました (ネイティブ SOAP 要求の場合と同様)。
ありがとう、ウィリアム