PHP consume Web service with data of type arrayofObjeto

0

I want to consume a web service from php shaped like this:

<s:element name="Metodo">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="Encabezado" type="tns:EncabezadoInicio" />
            <s:element minOccurs="0" maxOccurs="1" name="Lineas" type="tns:ArrayOfLinea" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="EncabezadoInicio">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Nombre" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Direccion" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Numero" type="s:string" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ArrayOfLinea">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="Linea" nillable="true" type="tns:Linea" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="Linea">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="codigo" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Cantidad" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Descripcion" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Precio" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Descuento" type="s:string" />
        </s:sequence>
      </s:complexType>    
How can I consume this web service? since the data sent is of another type of objects that are not string, any idea?

Now what I have only is an object whose indexes it has

      $Encabezado['Nombre']               = 'Su nombre';
      $Encabezado['Direccion']              = 'su direccion';
      $Encabezado['Numero']              = 'su numero';
      
  // como envio las lineas?
  
  
    
asked by Paola Casiano sipac 12.07.2018 в 18:04
source

1 answer

0

I have already solved it. The web service allows to send more lines of the same type, so what I did was an accountant

public function obtener_ArrayLineas($dato){
  $array_lineas= metodo_obtener_detalle($dato);
  $ArrayOfLineas= [];
  //ese metodo devuelve un objeto con el detalle del documento

  foreach($array_lineas as $key=>$detalle){
    $ArrayOfLineas['Linea'][] = $detalle;
  }
  
  return $ArrayOfLineas;
}

So when I send the ws method the parameter that I sent is

['Lines' => $ this-> get_ArrayLineas ($ data)]

And the header parameter

    
answered by 22.08.2018 / 17:20
source