【发布时间】:2015-05-20 18:53:43
【问题描述】:
我已经使用 AXIS 部署了一个 SOAP WS。我在 Ubuntu 14.04 上使用 SOAPClient 库和 PHP 5.5.9 来调用公开的操作,但是当我进行“__SoapCall”时它什么也不返回。我也尝试过使用“NuSOAP”库,但我得到了相同的结果。 但是当我调用“__getLastResponse”时,它会返回良好的响应(虽然重复),如您所见:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<idXMLReturn xmlns="http://aemetproyecto">PD94bWwgdm...</idXMLReturn>
</soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<idXMLReturn xmlns="http://aemetproyecto">PD94bWwgdm...</idXMLReturn>
</soapenv:Body>
</soapenv:Envelope>
我的 PHP 代码:
<?php
function generarTabla($id, $formato){
try{
// Create the SoapClient instance
$url = "http://localhost:8080/axis/services/AemetProyect?wsdl";
$client = new SoapClient($url, array("trace" => 1, "exception" => 1));
// Creo XML
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml .= "<!DOCTYPE id [\n";
$xml .= "<!ELEMENT id (#PCDATA)>\n";
$xml .= "]>\n";
$xml .= "<id>".$id."</id>";
// Codifico XML en Base64
$Base64xml = base64_encode($xml);
// Llamada SOAP a DescargarInfoTiempo
$resultado = $client -> __soapCall("DescargarInfoTiempo",
array($Base64xml));
//$resultado = $client -> __getLastResponse();
//echo $resultado;
//$resultado = $client -> __getLastRequest();
//echo $resultado;
echo $resultado;
} catch (SoapFault $ex){
$error = "SOAP Fault: (faultcode: {$ex->faultcode}\n"
."faultstring: {$ex->faultstring})";
echo $error;
} catch (Exception $e){
$error = "Exception: {$e->faultstring}";
echo $error;
}
}
?>
我注意到返回元素的名称(“idXMLReturn”)与 WSDL 中描述的名称(“DescargarInfoTiempoReturn”)不同。 会不会是这个问题?
更新
我已经尝试过:
$argumens['idXML'] = $Base64xml;
$resultado = $client -> __soapCall("DescargarInfoTiempo",
array($arguments));
和
$arguments['idXML'] = $Base64xml;
$resultado = $client ->DescargarInfoTiempo($arguments);
但是当我调用时,我得到“注意:数组到字符串的转换”。
【问题讨论】:
-
贴出你的PHP代码,让我们看看你有没有错误。
标签: php web-services soap wsdl axis