WSCOMUN  2.0.0
Web Services Comunes para PHP/GVHidra
WSClientGDE.php
1 <?php
2 namespace WSCOMUN\GDE;
4 use ArrayObject;
5 use Exception;
6 use SoapVar;
7 
19 {
20 
41  public function insertarDocumentoGDE($codApp, $docContentB64, $nombreDoc, $pathDoc='', $vMetadatosENI=null, $vMetadatosPersonalizados=null)
42  {
43  try
44  {
45  $this->__clienteOn(self::KEYCLIENTE_GDE, true);
46  $clienteWS = $this->v_clienteWS[self::KEYCLIENTE_GDE];
47 
48 
49  $insertarDocumentoWSRequest = new ArrayObject();
50  $insertarDocumentoWSRequest->append(new SoapVar($codApp, XSD_STRING, null, null,'codigoAplicacion', self::$NAMESPACE_GDE));
51 
52  $peticionWSRequest = new ArrayObject();
53  $peticionWSRequest->append(new SoapVar($docContentB64, XSD_STRING, null, null,'contenido', self::$NAMESPACE_GDE));
54  $peticionWSRequest->append(new SoapVar($nombreDoc, XSD_STRING, null, null,'nombre', self::$NAMESPACE_GDE));
55 
56  if (!empty($pathDoc))
57  {
58  $peticionWSRequest->append(new SoapVar($pathDoc, XSD_STRING, null, null,'path', self::$NAMESPACE_GDE));
59  }
60 
61  $insertarDocumentoWSRequest->append(new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'peticion', self::$NAMESPACE_GDE));
62  $miSoapRQ = new SoapVar($insertarDocumentoWSRequest, SOAP_ENC_OBJECT,null,null,'insertarDocumento', self::$NAMESPACE_GDE);
63  $respuesta = $clienteWS->insertarDocumento($miSoapRQ);
64 
65  //Metadatos ENI
66  if (is_array($vMetadatosENI))
67  {
68  $objMetadatosENI =$this->array2ObjectTree($vMetadatosENI);
69  $peticionWSRequest->append(new SoapVar($objMetadatosENI, SOAP_ENC_OBJECT, null, null,'metadatosENI', self::$NAMESPACE_GDE));
70  }
71 
72  //Metadatos Personalizados
73  if (is_array($vMetadatosPersonalizados))
74  {
75  $objMetadatosPersonalizados = $this->array2ObjectTree($vMetadatosPersonalizados);
76  $peticionWSRequest->append(new SoapVar($objMetadatosPersonalizados, SOAP_ENC_OBJECT, null, null,'coleccionMetadatosPersonalizados', self::$NAMESPACE_GDE));
77  }
78 
79  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
80  if (is_object($respuesta))
81  {
82  $vRespuesta = array
83  (
84  'referenciaDocumento' =>$respuesta->respuesta->referenciaDocumento,
85  'nombre' => $respuesta->respuesta->nombre
86  );
87  }
88  return($vRespuesta);
89  }
90  catch (Exception $e)
91  {
92  if ($this->getDebugMode())
93  {
94  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
95  if (is_object($clienteWS))
96  {
97  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
98  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
99  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
100  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
101  }
102  throw $e;
103  }
104  else
105  {
106  throw $e;
107  }
108  }
109  }//insertarDocumentoGDE
110 
111 
112 
123  public function obtenerDocumentoGDE($codApp, $refDoc, $parcial='1')
124  {
125  try
126  {
127  $opcionesClienteWS = array (
128  'soap_version' => SOAP_1_1, //SOAP 1.2
129  'user_agent' => 'WSSSoapClient',
130  'exceptions' => true,
131  'cache_wsdl' => self::$MYSOAPOP_WSDL_CACHE,
132  'trace' => self::$MYSOAPOP_TRACE
133  );
134 
135  $this->__clienteOn(self::KEYCLIENTE_GDE, true, $opcionesClienteWS);
136 
137  $clienteWS = $this->__getClient(self::KEYCLIENTE_GDE);
138 
139  $obtenerDocumentoWSRequest = new ArrayObject();
140  $obtenerDocumentoWSRequest->append(new SoapVar($codApp, XSD_STRING, null, null,'codigoAplicacion', self::$NAMESPACE_GDE));
141 
142  $peticionWSRequest = new ArrayObject();
143  $peticionWSRequest->append(new SoapVar($refDoc, XSD_STRING, null, null,'referenciaDocumento', self::$NAMESPACE_GDE));
144  $peticionWSRequest->append(new SoapVar($parcial, XSD_STRING, null, null,'parcial', self::$NAMESPACE_GDE));
145  $obtenerDocumentoWSRequest->append(new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'peticion', self::$NAMESPACE_GDE));
146 
147  $miSoapRQ = new SoapVar($obtenerDocumentoWSRequest, SOAP_ENC_OBJECT,null,null,'obtenerDocumento', self::$NAMESPACE_GDE);
148  $respuesta = $clienteWS->obtenerDocumento($miSoapRQ);
149 
150  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
151  if (is_object($respuesta))
152  {
153  $vRespuesta = $this->objectTree2array($respuesta);
154  }
155  return($vRespuesta);
156  }
157  catch (Exception $e)
158  {
159  // Comprobamos si estamos ante excepcion MTOM
160  $mensaje = $e->getMessage();
161  $mensaje = trim(strtolower($mensaje));
162  if ($mensaje == 'looks like we got no xml document')
163  {
164  $response = $clienteWS->__getLastResponse();
165  $vRetorno = $this->tratarMTOMEstandar($response);
166  return ($vRetorno);
167  }
168  else if ($this->getDebugMode())
169  {
170  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
171  if (is_object($clienteWS))
172  {
173  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
174  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
175  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
176  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
177  }
178  throw $e;
179  }
180  else
181  {
182  throw $e;
183  }
184  }
185  }//obtenerDocumentoGDE
186 
187 
197  public function eliminarDocumentoGDE($codApp, $refDoc)
198  {
199  //$this->setDebugMode(true);
200  try
201  {
202  $opcionesClienteWS = array (
203  'soap_version' => SOAP_1_1, //SOAP 1.2
204  'user_agent' => 'WSSSoapClient',
205  'exceptions' => true,
206  'cache_wsdl' => self::$MYSOAPOP_WSDL_CACHE,
207  'trace' => self::$MYSOAPOP_TRACE
208  );
209 
210  $this->__clienteOn(self::KEYCLIENTE_GDE, true, $opcionesClienteWS);
211 
212  $clienteWS = $this->__getClient(self::KEYCLIENTE_GDE);
213 
214  $obtenerDocumentoWSRequest = new ArrayObject();
215  $obtenerDocumentoWSRequest->append(new SoapVar($codApp, XSD_STRING, null, null,'codigoAplicacion', self::$NAMESPACE_GDE));
216 
217  $peticionWSRequest = new ArrayObject();
218  $peticionWSRequest->append(new SoapVar($refDoc, XSD_STRING, null, null,'referenciaDocumento', self::$NAMESPACE_GDE));
219  $obtenerDocumentoWSRequest->append(new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'peticion', self::$NAMESPACE_GDE));
220 
221  $miSoapRQ = new SoapVar($obtenerDocumentoWSRequest, SOAP_ENC_OBJECT,null,null,'eliminarDocumento', self::$NAMESPACE_GDE);
222  $respuesta = $clienteWS->eliminarDocumento($miSoapRQ);
223 
224  $vRespuesta = array();//RABA0f8f9d62-08fc-4a8e-98e9-f23898075b37
225  if (is_object($respuesta))
226  {
227  $vRespuesta = $this->objectTree2array($respuesta);
228  }
229  return($vRespuesta);
230  }
231  catch (Exception $e)
232  {
233  $mensaje = $e->detail->ExcepcionWS->detalleError;
234  $mensaje = trim(strtolower($mensaje));
235  if (strpos($mensaje, 'ya estaba borrado')===false)
236  {
237  if ($this->getDebugMode())
238  {
239  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
240  if (is_object($clienteWS))
241  {
242  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
243  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
244  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
245  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
246  }
247  throw $e;
248  }
249  }
250  else
251  {
252  return array('correcto'=>false);
253  }
254  }
255  }//eliminarDocumentoGDE
256 
257 
258 
268  public function eliminarCarpetaGDE($codApp, $path)
269  {
270  try
271  {
272  $opcionesClienteWS = array (
273  'soap_version' => SOAP_1_1, //SOAP 1.2
274  'user_agent' => 'WSSSoapClient',
275  'exceptions' => true,
276  'cache_wsdl' => self::$MYSOAPOP_WSDL_CACHE,
277  'trace' => self::$MYSOAPOP_TRACE
278  );
279 
280  $this->__clienteOn(self::KEYCLIENTE_GDE, true, $opcionesClienteWS);
281 
282  $clienteWS = $this->__getClient(self::KEYCLIENTE_GDE);
283 
284  $obtenerDocumentoWSRequest = new ArrayObject();
285  $obtenerDocumentoWSRequest->append(new SoapVar($codApp, XSD_STRING, null, null,'codigoAplicacion', self::$NAMESPACE_GDE));
286 
287  $peticionWSRequest = new ArrayObject();
288  $peticionWSRequest->append(new SoapVar($path, XSD_STRING, null, null,'path', self::$NAMESPACE_GDE));
289  $obtenerDocumentoWSRequest->append(new SoapVar($peticionWSRequest, SOAP_ENC_OBJECT,null,null,'peticion', self::$NAMESPACE_GDE));
290 
291  $miSoapRQ = new SoapVar($obtenerDocumentoWSRequest, SOAP_ENC_OBJECT,null,null,'eliminarCarpeta', self::$NAMESPACE_GDE);
292  $respuesta = $clienteWS->eliminarCarpeta($miSoapRQ);
293 
294  $vRespuesta = array();
295  if (is_object($respuesta))
296  {
297  $vRespuesta = $this->objectTree2array($respuesta);
298  }
299  return($vRespuesta);
300  }
301  catch (Exception $e)
302  {
303  if ($this->getDebugMode())
304  {
305  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
306  if (is_object($clienteWS))
307  {
308  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
309  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
310  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
311  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
312  }
313  throw $e;
314  }
315  else
316  {
317  throw $e;
318  }
319  }
320  }//eliminarCarpetaGDE
321 
322 }
323 
324 
325 ?>
__clienteOn($tipo, $trazabilidadPai=true, $opcionesClienteWS=null)
obtenerDocumentoGDE($codApp, $refDoc, $parcial='1')
eliminarDocumentoGDE($codApp, $refDoc)
insertarDocumentoGDE($codApp, $docContentB64, $nombreDoc, $pathDoc='', $vMetadatosENI=null, $vMetadatosPersonalizados=null)
Definition: WSClientGDE.php:41
tratarMTOMEstandar($response, $itemToReturn=null)
eliminarCarpetaGDE($codApp, $path)