【问题标题】:get array result with wsdl and complexType使用 wsdl 和 complexType 获取数组结果
【发布时间】:2014-11-24 14:57:28
【问题描述】:

我需要发送一个日期并获得一个记录数组,以获得响应。我的问题是如何在 WSDL 中定义复杂类型。

这个link 向我展示了一种对我不起作用的方法

【问题讨论】:

    标签: xml soap wsdl


    【解决方案1】:

    我的网络服务:

        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);
    }
    

    我没有数据返回一个对象

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-30
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-15
      • 1970-01-01
      相关资源
      最近更新 更多