我在centos服务器(PHP 5.2.10,apache / 2.2.3)上设置了wso2 PHP WS 2.1.0框架,并且本机PHP SOAP扩展是活动的。示例WS客户端工作正常。我的WS安装到默认值的唯一区别是wsf文件位于路径结构/ usr / lib64 / php / modules / wsf_c /而不是/ var / lib /。
我无法使用以下客户端脚本生成完整的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)无法获取根节点'。
我假设在getLastRequest的打印输出中的body元素中缺少xml请求的事实,我需要以不同方式格式化有效负载xml - 可能使用命名空间?
我不确定这应该如何看待,如果这是问题,那么非常感谢任何建议。我在WSClient数组中引用和不使用'wsdl'时尝试过此请求,并尝试将有效内容定义为数组而不是XML字符串(就像使用本机SOAP请求一样)。
谢谢你,威廉