我需要发送一个日期并获得一系列记录获得的响应。我的问题是如何在WSDL中定义复杂类型。
这link告诉我一种方式对我不起作用
答案 0 :(得分:0)
我的网络服务:
function pagos($fecha){
require_once "include/conexion.php";
$result = sqlsrv_query2("
consulta");
$datos = array();
$c=0;
while($row = sqlsrv_fetch_array($result)){
for($i = 0; $i<6;$i++){
$datos[$c][$i]=$row[$i];
}
$c++;
}
return $datos; //devuelvo un array multidimensional de 6 columnas
}
$server->AddFunction("pagos");
$server->handle();`enter code here
我的WSDL:
<?xml version="1.0"?>
<definitions name="AritmeticaServicio"
targetNamespace="urn:Aritmetica"
xmlns:tns="urn:Aritmetica"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="urn:Aritmetica">
<xsd:complexType name="resultArray">
<complexContent>
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="xsd:string[][]"/>
</restriction>
</complexContent>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<message name="AritmeticaPeticion">
<part name="operando1" type="xsd:string" />
</message>
<message name="AritmeticaRespuesta">
<part name="respuesta" type="xsd:resultArray" />
</message>
<portType name="AritmeticaPort">
<operation name="pagos">
<input message="tns:AritmeticaPeticion" />
<output message="tns:AritmeticaRespuesta" />
</operation>
</portType>
<binding name="AritmeticaBinding" type="tns:AritmeticaPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="pagos">
<soap:operation soapAction="urn:Aritmetica#pagos" />
<input>
<soap:body use="encoded" namespace="urn:Aritmetica"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:Aritmetica"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="AritmeticaServicio">
<port name="AritmeticaPort" binding="tns:AritmeticaBinding">
<soap:address location="http://localhost:8080/proyecto/server.php" />
</port>
</service>
</definitions>
我打电话给客户
try{
$clienteSOAP = new SoapClient('http://localhost:8080/proyecto/aritmetica.wsdl');
$resultado_pago = $clienteSOAP->pagos('2014-06-30');
echo '<pre>';
var_dump($resultado_pago);
} catch(SoapFault $e){
echo '<pre>';
print_r($e);
}
我没有数据返回对象