ORVE WS (Dynamic) (7) Testing obtenerRegistro operation
0. Introduction
When a record (registro) is introduced in the online ORVE application, 2 identifiers are created for the same record, one as a sending record and another one as a reception record.
ORVE WS cannot be used to input records to the application, but to retrieve the records that are sent or received by the administration the user has permission to access.
Usually, all the records that are sent to our administration should be internally registered, but not all the records that we send to other administration should be registered internally.
In a future post, a method to register to a local application will be analyzed.
In order to get a record, an id is needed.
1. Retrieving the ids
In a previous post, we have implemented static and dynamic clients to get the ids of the records that fulfil some conditions.2. Invoking the obtenerRegistro operation
Let's create a simple class to retrieve a record. It is important to notice that part of the response has a Sicres 3.0 structure, that has been seen in previous posts (this and this).Here is the source of a simple dynamic client class. A valid id is 955434 (line 40)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | package ximodante.orve.dynamicp; import java.util.HashMap; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import ximodante.utils.ObjectBuilder; public class DynamicORVEClient02 { public static void main(String[] args) { try { //1. Declare WSDL JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("https://ssweb.seap.minhap.es/demoorve/WSExportacion.wsdl"); //1.1 INTERCEPTOR !!! //var myInterceptor = new MyXMLInterceptor<Message>(); //client.getInInterceptors().add(myInterceptor); // 2. Create a map to store fields var mapFields=new HashMap<String,Object>(); // 3. Create parameters of the WS operations // 3.1 Security // 3.1.1 Assign fields mapFields.clear(); // remove previous fields mapFields.put("username", "myUser"); mapFields.put("password", "myPassword"); //3.1.2 Create object var security=ObjectBuilder.getObject("https.ssweb_seap_minhap_es.demoorve.Security", mapFields); // 3.-2 Known id int id = 955434; Object[] reg = client.invoke("obtenerRegistro",security,id); String cod = (String)(FieldUtils.readField( reg[1], "codigo", true)); String descr = (String)(FieldUtils.readField( reg[1], "descripcion", true)); String registro =(String)(FieldUtils.readField( reg[1], "registro", true)); if (! cod.equals("00") ) System.out.println("Error " + cod + ": " + descr); else System.out.println(registro.substring(1, 600)); } catch (Exception e) { e.printStackTrace(); } } } |
and the output is
1 2 3 4 5 6 7 | ?xml version="1.0" encoding="UTF-8"?><Fichero_Intercambio_SICRES_3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <De_Origen_o_Remitente> <Codigo_Entidad_Registral_Origen>O00002741</Codigo_Entidad_Registral_Origen> <Decodificacion_Entidad_Registral_Origen>Registro General del Ayuntamiento de Jun</Decodificacion_Entidad_Registral_Origen> <Numero_Registro_Entrada>O00002741_18_0001132</Numero_Registro_Entrada> <Fecha_Hora_Entrada>20180913124433</Fecha_Hora_Entrada> <Timestamp_Entrada>MIIhJgYJKoZIhvcNAQcCoIIhFzCCIRMCAQMxCzAJBgUrDgMCGgUAMIIU3AYLKoZIhvcNAQkQAQSgghTLBIIUx |
One can realize that this is an XML output whose schema is "Sicres30".
Comments
Post a Comment