Dynamic WS Clients. Eureka! 1. Getting Information from the WSDL

0. Introduction


It has been a hard work for me achieving this goal. I have been trying to find free and simple WS on the web to help me implement dynamic WS clients. I have been googling around and finally, this simple web service was near me. "Gexflow" offers a lot of simple and easy WS.

I have been looking around to find easy examples of dynamic WS clients and none of the satisfied my needs. After reading this official post for Apache CXF and bit of practice I can say Eureka!

Now I want to convert my application from static WS client to dynamic WS client. Now I do not need all the scaffolding of classes generated with Apache CXF command "wsdl2java" that by the moment needs Java 8.

Let's begin understanding the WSDL and selecting the WS we need. We are going to focus on the operation "registrarAsientoEntrada" that means inserting a row in the "entrance record".

1. Getting information from the WSDL



Here is the information that the WSDL has about this operation


<wsdl:operation name="registrarAsientoEntrada">
<wsdl:input message="tns:registrarAsientoEntrada" name="registrarAsientoEntrada"></wsdl:input>
<wsdl:output message="tns:registrarAsientoEntradaResponse" name="registrarAsientoEntradaResponse"></wsdl:output>
<wsdl:fault message="tns:WSException" name="WSException"></wsdl:fault>
</wsdl:operation>

We can see that :

  1. There is a namespace called "tns".
  2. There is an input data structure called  "registrarAsientoEntrada".
  3. There is an output data structure called "registrarAsientoEntradaResponse".
  4. Throws an exception called "WSException"

2. Analyzing the input data structure in the WSDL


For the input data structure, the WSDL gives us the definition:


<xs:complexType name="registrarAsientoEntrada">
<xs:sequence>
<xs:element minOccurs="0" name="idEntidad" type="xs:int"/>
<xs:element minOccurs="0" name="codUnidadRegistral" type="xs:string"/>
<xs:element minOccurs="0" name="codigoOficina" type="xs:string"/>
<xs:element minOccurs="0" name="usuario" type="xs:string"/>
<xs:element minOccurs="0" name="fechaValor" type="xs:dateTime"/>
<xs:element minOccurs="0" name="motivoCambioFechaValor" type="xs:string"/>
<xs:element minOccurs="0" name="fechaDocumento" type="xs:dateTime"/>
<xs:element minOccurs="0" name="claseDocumento" type="xs:string"/>
<xs:element minOccurs="0" name="modoRecepcion" type="xs:string"/>
<xs:element minOccurs="0" name="asunto" type="xs:string"/>
<xs:element minOccurs="0" name="referenciaExpediente" type="xs:string"/>
<xs:element minOccurs="0" name="numeroTransporte" type="xs:string"/>
<xs:element minOccurs="0" name="soporte" type="xs:string"/>
<xs:element minOccurs="0" name="resumen" type="xs:string"/>
<xs:element minOccurs="0" name="tipoInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="tipoDocumento" type="xs:string"/>
<xs:element minOccurs="0" name="documentoInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="nombreInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="documentoRepresentante" type="xs:string"/>
<xs:element minOccurs="0" name="nombreRepresentante" type="xs:string"/>
<xs:element minOccurs="0" name="organo" type="xs:string"/>
<xs:element minOccurs="0" name="cargo" type="xs:string"/>
<xs:element minOccurs="0" name="correoElectronico" type="xs:string"/>
<xs:element minOccurs="0" name="telefono" type="xs:string"/>
<xs:element minOccurs="0" name="tipoVia" type="xs:string"/>
<xs:element minOccurs="0" name="via" type="xs:string"/>
<xs:element minOccurs="0" name="numeroVia" type="xs:int"/>
<xs:element minOccurs="0" name="letra" type="xs:string"/>
<xs:element minOccurs="0" name="bloque" type="xs:string"/>
<xs:element minOccurs="0" name="portal" type="xs:string"/>
<xs:element minOccurs="0" name="escalera" type="xs:string"/>
<xs:element minOccurs="0" name="piso" type="xs:string"/>
<xs:element minOccurs="0" name="puerta" type="xs:string"/>
<xs:element minOccurs="0" name="codigoPostal" type="xs:string"/>
<xs:element minOccurs="0" name="municipio" type="xs:string"/>
<xs:element minOccurs="0" name="provincia" type="xs:string"/>
<xs:element minOccurs="0" name="nucleo" type="xs:string"/>
<xs:element minOccurs="0" name="codUnidadOrganizativaRemitente" type="xs:string"/>
<xs:element minOccurs="0" name="destinosInternos" type="tns:destinoRegistroEntradaWSJB"/>
</xs:sequence>
</xs:complexType>

There are a lot of simple attributes (string, int) but there is a complex attribute of type "destinoRegistroEntradaWSJB", and we need to look for its structure in the WSDL and here it is:


<xs:complexType name="destinoRegistroEntradaWSJB">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="codigosUnidadesOrganizativasDestino" nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="unidadesOrganizativasDestino" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>

It is comparable to a List.

Now we have all the input data structure seen. Let's see the output data structure

3. Analyzing the output data structure in the WSDL

For this element the WDSL inform us this way:


<xs:complexType name="registrarAsientoEntradaResponse">
<xs:sequence>
<xs:element minOccurs="0" name="salida" type="tns:registroEntradaWSV2JB"/>
</xs:sequence>
</xs:complexType>


But there is another complex structure called "registroEntradaWSV2JB" whose definition is:



<xs:complexType name="registroEntradaWSV2JB">
<xs:sequence>
<xs:element minOccurs="0" name="anyo" type="xs:string"/>
<xs:element minOccurs="0" name="asunto" type="xs:string"/>
<xs:element minOccurs="0" name="bloque" type="xs:string"/>
<xs:element minOccurs="0" name="cargo" type="xs:string"/>
<xs:element minOccurs="0" name="claseDocumento" type="xs:string"/>
<xs:element minOccurs="0" name="codUnidadOrganizativaRemitente" type="xs:string"/>
<xs:element minOccurs="0" name="codUnidadRegistral" type="xs:string"/>
<xs:element minOccurs="0" name="codigoOficina" type="xs:string"/>
<xs:element minOccurs="0" name="codigoPostal" type="xs:string"/>
<xs:element minOccurs="0" name="correoElectronico" type="xs:string"/>
<xs:element minOccurs="0" name="destinosInternos" type="tns:destinoRegistroEntradaWSJB"/>
<xs:element minOccurs="0" name="documentoInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="documentoRepresentante" type="xs:string"/>
<xs:element minOccurs="0" name="entidad" type="xs:string"/>
<xs:element minOccurs="0" name="escalera" type="xs:string"/>
<xs:element minOccurs="0" name="estado" type="xs:string"/>
<xs:element minOccurs="0" name="fechaAsiento" type="xs:dateTime"/>
<xs:element minOccurs="0" name="fechaDocumento" type="xs:dateTime"/>
<xs:element minOccurs="0" name="fechaValor" type="xs:dateTime"/>
<xs:element minOccurs="0" name="idEntidad" type="xs:int"/>
<xs:element minOccurs="0" name="letra" type="xs:string"/>
<xs:element minOccurs="0" name="metadatos" type="xs:string"/>
<xs:element minOccurs="0" name="modoRecepcion" type="xs:string"/>
<xs:element minOccurs="0" name="motivoCambioFechaValor" type="xs:string"/>
<xs:element minOccurs="0" name="municipio" type="xs:string"/>
<xs:element minOccurs="0" name="nombreInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="nombreRepresentante" type="xs:string"/>
<xs:element minOccurs="0" name="nucleo" type="xs:string"/>
<xs:element minOccurs="0" name="numero" type="xs:string"/>
<xs:element minOccurs="0" name="numeroTransporte" type="xs:string"/>
<xs:element minOccurs="0" name="numeroVia" type="xs:int"/>
<xs:element minOccurs="0" name="oficina" type="xs:string"/>
<xs:element minOccurs="0" name="organo" type="xs:string"/>
<xs:element minOccurs="0" name="piso" type="xs:string"/>
<xs:element minOccurs="0" name="portal" type="xs:string"/>
<xs:element minOccurs="0" name="provincia" type="xs:string"/>
<xs:element minOccurs="0" name="puerta" type="xs:string"/>
<xs:element minOccurs="0" name="referenciaExpediente" type="xs:string"/>
<xs:element minOccurs="0" name="resultado" type="xs:string"/>
<xs:element minOccurs="0" name="resumen" type="xs:string"/>
<xs:element minOccurs="0" name="soporte" type="xs:string"/>
<xs:element minOccurs="0" name="telefono" type="xs:string"/>
<xs:element minOccurs="0" name="tipoDocumento" type="xs:string"/>
<xs:element minOccurs="0" name="tipoInteresado" type="xs:string"/>
<xs:element minOccurs="0" name="tipoVia" type="xs:string"/>
<xs:element minOccurs="0" name="unidadOrganizativaRemitente" type="xs:string"/>
<xs:element minOccurs="0" name="unidadRegistral" type="xs:string"/>
<xs:element minOccurs="0" name="via" type="xs:string"/>
</xs:sequence>
</xs:complexType>

This structure is similar to the input one and shares the complex type "destinoRegistroEntradaWSJB" too.

I am not going to deal with the exception "WSException" in this post.

Now we know what are the required data structures to manage this operation.


4. Java package names and fully qualified class names


We can get the Java package names from the beginning of the WDSL file:

<wsdl:types>
<xs:schema xmlns:ns0="http://gexflow.com" xmlns:tns="http://gexflow/reges" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://gexflow/reges">
<xs:element name="adjuntarDocumentoARegistro" type="tns:adjuntarDocumentoARegistro"/>

......

<xs:element name="registrarAsientoEntrada" type="tns:registrarAsientoEntrada"/>
<xs:element name="registrarAsientoEntradaResponse" type="tns:registrarAsientoEntradaResponse"/>

The package name is got from xmlns:tns="http://gexflow/reges" and is "gexflow.reges". For instance the class "registrarAsientoEntrada" has its full name( with its package)  "gexflow.reges.RegistrarAsientoEntrada"

Comments

Popular posts from this blog

ORVE WS (Dynamic) (4) Jackson XML mapper

ENI (1) ENI Document OR the Spanish Electronic Administration Mafia

ORVE WS (Dynamic) (12) Defiining the control tables