WSCOMUN  2.1.0
Web Services Comunes para PHP/GVHidra
WSClientCSV.php
1 <?php
2 namespace WSCOMUN\CSV;
4 use ArrayObject;
5 use DateTime;
6 use Exception;
7 use SoapVar;
19 {
20 
21  public function csv_encodeClaveAcceso($appID, $nif, $referenciaExterna, $firmante)
22  {
23  $claveAccesoWSRequest = new ArrayObject();
24  $claveAccesoWSRequest->append(new SoapVar($appID, XSD_STRING, null, null,'aplicacionId'));
25  $claveAccesoWSRequest->append(new SoapVar($nif, XSD_STRING, null, null,'nif'));
26  $claveAccesoWSRequest->append(new SoapVar($referenciaExterna, XSD_STRING, null, null,'referenciaExterna'));
27  $claveAccesoWSRequest->append(new SoapVar($firmante, XSD_STRING, null, null,'firmante'));
28 
29  return $claveAccesoWSRequest;
30  }//csv_encodeClaveAcceso
31 
32  public function obtenerCodigo($appID, $nif, $referenciaExterna, $firmante,
33  $generarBarCode=null, $tipoBarCode=null, $width=null, $height=null)
34  // $docContentB64=null, $nombreDoc=null, $pathDoc='', $vMetadatosENInull, $vMetadatosPersonalizados=null)
35  {
36  try
37  {
38  $this->__clienteOn(self::KEYCLIENTE_CSV, true);
39  $clienteWS = $this->__getClient(self::KEYCLIENTE_CSV);
40 
41  $claveAccesoWSRequest = $this->csv_encodeClaveAcceso($appID, $nif, $referenciaExterna, $firmante);
42 
43  $opcGeneracionWSRequest = new ArrayObject();
44  if (!empty($generarBarCode))
45  $opcGeneracionWSRequest->append(new SoapVar($generarBarCode, XSD_STRING, null, null,'generarBarCode'));
46  if (!empty($tipoBarCode))
47  $opcGeneracionWSRequest->append(new SoapVar($tipoBarCode, XSD_STRING, null, null,'tipoBarCode'));
48  if (!empty($width))
49  $opcGeneracionWSRequest->append(new SoapVar($width, XSD_STRING, null, null,'width'));
50  if (!empty($height))
51  $opcGeneracionWSRequest->append(new SoapVar($height, XSD_STRING, null, null,'height'));
52 
53  // Global
54  $claveAcceso2WSRequest = new ArrayObject();
55  $claveAcceso2WSRequest->append(new SoapVar($claveAccesoWSRequest, SOAP_ENC_OBJECT, null, null,'claveAcceso'));
56  $claveAcceso2WSRequest->append(new SoapVar($opcGeneracionWSRequest, SOAP_ENC_OBJECT, null, null,'opcionesGeneracion'));
57 
58  // Realiza la solicitud
59  $peticionWSRequest = new ArrayObject();
60  $peticionWSRequest->append(new SoapVar($claveAcceso2WSRequest, SOAP_ENC_OBJECT,null,null,'peticion'));
61  $miSoapRQ = new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'obtenerCSVRequest', self::$NAMESPACE_CSVGVA);
62 
63  $respuesta = $clienteWS->obtenerCSV($miSoapRQ);
64  //var_dump($respuesta->respuesta);die;
65 
66 
67  // Respuesta
68  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
69  if (is_object($respuesta))
70  {
71  $vRespuesta = array
72  (
73  'csv' => $respuesta->respuesta->csv,
74  'url' => $respuesta->respuesta->url,
75  );
76  if (isset($respuesta->respuesta->imagenBarCode))
77  $vRespuesta['imagenBarCode'] = $respuesta->respuesta->imagenBarCode;
78  }
79  return($vRespuesta);
80  }
81  catch (Exception $e)
82  {
83  $this->tratarExcepcionEstandar($e, $clienteWS);
84  }
85  }//obtenerCodigo
86 
87  public function asociarCSV($csv, $appID, $nif, $referenciaExterna, $firmante,
88  $idRepositorio, $refDoc, $hash, $fechaCaducidad = null, $vParametros = null)
89  {
90  try
91  {
92  $this->__clienteOn(self::KEYCLIENTE_CSV, true);
93  $clienteWS = $this->__getClient(self::KEYCLIENTE_CSV);
94 
95 
96  $claveAccesoWSRequest = $this->csv_encodeClaveAcceso($appID, $nif, $referenciaExterna, $firmante);
97 
98  $infDocWSRequest = new ArrayObject();
99  $infDocWSRequest->append(new SoapVar($idRepositorio, XSD_STRING, null, null,'idRepositorio'));
100  $infDocWSRequest->append(new SoapVar($refDoc, XSD_STRING, null, null,'referenciaDocumento'));
101  $infDocWSRequest->append(new SoapVar($hash, XSD_STRING, null, null,'hash'));
102  if (!empty($fechaCaducidad))
103  $infDocWSRequest->append(new SoapVar($fechaCaducidad->format(DateTime::ATOM), XSD_STRING, null, null,'fechaCaducidad'));
104  if (is_array($vParametros)) {
105 
106  $parametrosVerificacion = new ArrayObject();
107 
108  foreach ($vParametros as $itemParametro) {
109  $parametro = new ArrayObject();
110  $parametro->append(new SoapVar($itemParametro['etiqueta'], XSD_STRING, null, null,'etiqueta'));
111  $parametro->append(new SoapVar($itemParametro['ayuda'], XSD_STRING, null, null,'ayuda'));
112  $parametro->append(new SoapVar($itemParametro['valor'], XSD_STRING, null, null,'valor'));
113 
114  $parametrosVerificacion->append(new SoapVar($parametro, SOAP_ENC_OBJECT, null, null,'parametro'));
115  }
116 
117  $infDocWSRequest->append(new SoapVar($parametrosVerificacion, SOAP_ENC_OBJECT, null, null,'parametrosVerificacion'));
118  }
119 
120  // Global
121  $claveAcceso2WSRequest = new ArrayObject();
122  $claveAcceso2WSRequest->append(new SoapVar($csv, XSD_STRING, null, null,'csv'));
123  $claveAcceso2WSRequest->append(new SoapVar($claveAccesoWSRequest, SOAP_ENC_OBJECT, null, null,'claveAcceso'));
124  $claveAcceso2WSRequest->append(new SoapVar($infDocWSRequest, SOAP_ENC_OBJECT, null, null,'informacionDocumento'));
125 
126 
127 
128  // Realiza la solicitud
129  $peticionWSRequest = new ArrayObject();
130  $peticionWSRequest->append(new SoapVar($claveAcceso2WSRequest, SOAP_ENC_OBJECT,null,null,'peticion'));
131  $miSoapRQ = new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'asociarCSVRequest', self::$NAMESPACE_CSVGVA);
132  $respuesta = $clienteWS->asociarCSV($miSoapRQ);
133 
134  //var_dump($respuesta->respuesta->respuesta);die;
135 
136  // Respuesta
137  $vRespuesta = array();
138  if (is_object($respuesta))
139  {
140  $vRespuesta = array
141  (
142  'respuesta' => $respuesta->respuesta->respuesta
143  );
144  }
145  return($vRespuesta);
146  }
147  catch (Exception $e)
148  {
149  $this->tratarExcepcionEstandar($e, $clienteWS);
150  }
151  }//asociarCSV
152 
153  public function invalidarCSV($csv, $appID, $nif, $referenciaExterna, $firmante)
154  {
155  try
156  {
157  $this->__clienteOn(self::KEYCLIENTE_CSV, true);
158  $clienteWS = $this->__getClient(self::KEYCLIENTE_CSV);
159 
160 
161  $claveAccesoWSRequest = $this->csv_encodeClaveAcceso($appID, $nif, $referenciaExterna, $firmante);
162 
163 
164  // Global
165  $claveAcceso2WSRequest = new ArrayObject();
166  $claveAcceso2WSRequest->append(new SoapVar($csv, XSD_STRING, null, null,'csv'));
167  $claveAcceso2WSRequest->append(new SoapVar($claveAccesoWSRequest, SOAP_ENC_OBJECT, null, null,'claveAcceso'));
168 
169 
170 
171  // Realiza la solicitud
172  $peticionWSRequest = new ArrayObject();
173  $peticionWSRequest->append(new SoapVar($claveAcceso2WSRequest, SOAP_ENC_OBJECT,null,null,'peticion'));
174  $miSoapRQ = new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'invalidarCSVRequest', self::$NAMESPACE_CSVGVA);
175  $respuesta = $clienteWS->invalidarCSV($miSoapRQ);
176  //var_dump($respuesta->respuesta);die;
177 
178  // Respuesta
179  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
180  if (is_object($respuesta))
181  {
182  $vRespuesta = array
183  (
184  'respuesta' => $respuesta->respuesta->respuesta
185  );
186  }
187  return($vRespuesta);
188  }
189  catch (Exception $e)
190  {
191  $this->tratarExcepcionEstandar($e, $clienteWS);
192  }
193  }//invalidarCSV
194 
195  public function modificarFechaCaducidadCSV($csv, $appID, $nif, $referenciaExterna, $firmante, $fechaCaducidad)
196  {
197  try
198  {
199  $this->__clienteOn(self::KEYCLIENTE_CSV, true);
200  $clienteWS = $this->__getClient(self::KEYCLIENTE_CSV);
201 
202 
203  $claveAccesoWSRequest = $this->csv_encodeClaveAcceso($appID, $nif, $referenciaExterna, $firmante);
204 
205 
206  // Global
207  $claveAcceso2WSRequest = new ArrayObject();
208  $claveAcceso2WSRequest->append(new SoapVar($csv, XSD_STRING, null, null,'csv'));
209  $claveAcceso2WSRequest->append(new SoapVar($claveAccesoWSRequest, SOAP_ENC_OBJECT, null, null,'claveAcceso'));
210  $claveAcceso2WSRequest->append(new SoapVar($fechaCaducidad->format(DateTime::ATOM), XSD_STRING, null, null,'fechaCaducidad'));
211 
212 
213  // Realiza la solicitud
214  $peticionWSRequest = new ArrayObject();
215  $peticionWSRequest->append(new SoapVar($claveAcceso2WSRequest, SOAP_ENC_OBJECT,null,null,'peticion'));
216  $miSoapRQ = new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'modificarFechaCSVRequest', self::$NAMESPACE_CSVGVA);
217  $respuesta = $clienteWS->modificarFechaCSV($miSoapRQ);
218  //var_dump($respuesta->respuesta);die;
219 
220 
221  // Respuesta
222  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
223  if (is_object($respuesta))
224  {
225  $vRespuesta = array
226  (
227  'respuesta' => $respuesta->respuesta->respuesta
228  );
229  }
230  return($vRespuesta);
231  }
232  catch (Exception $e)
233  {
234  $this->tratarExcepcionEstandar($e, $clienteWS);
235  }
236  }//modificarFechaCaducidadCSV
237 
238 }
239 
240 ?>
__clienteOn($tipo, $trazabilidadPai=true, $opcionesClienteWS=null)