web services genexus tilo
DESCRIPTION
Web Services in GeneXus TiloTRANSCRIPT
![Page 1: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/1.jpg)
Servicios WEB: Integración de aplicaciones
Diciembre 2013
Artech
![Page 2: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/2.jpg)
SOAP
REST
HTTP
![Page 3: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/3.jpg)
Web SevicesSOAP
• Basado en XML• Modelo de comunicación HTTP
![Page 4: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/4.jpg)
Web Services en GeneXus
• Proveer• Procedimientos
• Call Protocol SOAP• Business Components, DataProviders
• Expose as Web Service• http://
wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?11231
• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?2282
![Page 5: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/5.jpg)
Web Services en GeneXus
• Consumidor• WSDL Import Wizardhttp://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?6181
![Page 6: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/6.jpg)
Definición del consumidor de un Web Service
Objetos Externos
Paso 1: Indicar la URL del Web Service que se quiere utilizar.
![Page 7: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/7.jpg)
Paso 2: Indicar el nombre que se le dará al External Object, su descripción, carpeta de ubicación y prefijo.
Definición del consumidor de un Web Service
Objetos Externos
![Page 8: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/8.jpg)
Paso 3: Una vez descubierto el Web Service, presionamos Import para importarlo.
Definición del consumidor de un Web Service
Objetos Externos
![Page 9: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/9.jpg)
Paso 4: Una vez importado el Web Service, vemos el objeto externo y sus propiedades (View/Properties o F4 sobre el Objeto Externo).
Definición del consumidor de un Web Service
Objetos Externos
![Page 10: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/10.jpg)
Para conocer la estructura del WS, damos botón derecho sobre el mismo y seleccionamos Open Part / Structure:
Conocemos los parámetros
Definición del consumidor de un Web Service
Objetos Externos
![Page 11: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/11.jpg)
Para consumir el WS definimos una variable basada en el tipo de dato CountryInfoService
y luego invocamos al método CapitalCity:
Definición del consumidor de un Web Service
Objetos Externos
![Page 12: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/12.jpg)
Web Services en GeneXusManejo de errores
http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?7021http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?7022
![Page 13: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/13.jpg)
• Para permitir configurar invocaciones a objetos main GeneXus en forma remota.
• Se pueden hacer usando el tipo de datos Location de GeneXus o el archivo location.xml.
• Instancias para configurar los locations:1. En tiempo de generación: mediante location.xml2. En tiempo de ejecución mediante un archivo: location.xml3. En tiempo de ejecución mediante código: utilizando variables tipo
Location
• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?6981
• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?6111
Web ServicesLocations
![Page 14: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/14.jpg)
Ejemplo
&location= GetLocation('WebserviceDatatype')&location.Host = Localhost &location.Port = 8085 &location.CancelOnError=2&location.Timeout=&timeout&outparam= &webservice.Method(&inparams)&SoapErr=GetSOAPErr()&SoapMsg=GetSOAPErrMsg()
![Page 15: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/15.jpg)
TroubleShooting
• Tcptrace http://www.gxtechnical.com/gxdlsp/dist/iehelp.htm?genexus/internet/technicalpapers/debugcallsoap.htm
• SoapUI
http://www.soapui.org/
![Page 16: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/16.jpg)
Rest
![Page 17: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/17.jpg)
Por qué REST?
• Optimización de tráfico• Accesible a cualquier cliente HTTP
Por qué
REST
![Page 18: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/18.jpg)
Qué es REST?
• Exponer recursos en la web en un formato estándar: XML, Json..
XML
….JSON
Qué
Es
REST
![Page 19: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/19.jpg)
…Invocando un servicio RESTQué
Es
REST
![Page 20: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/20.jpg)
RESTful Web Services
• Sintáxis universal para identificar los recursos (URI)
• Definición de una representación del estado• MIME TYPE: XML, Json..
• Interfaz Uniforme(GET, POST, PUT, DELETE)
Qué
Es
REST
![Page 21: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/21.jpg)
Analogía CRUD
Resource POST GET PUT DELETE
URI: http://server/Product/123
Create Read Update Delete
Qué
Es
REST
![Page 22: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/22.jpg)
REST a la luz de GeneXus
• Business Components• Create (POST), Read (GET),
Update (PUT), Delete (DELETE)
• Data Providers• Read (GET)
• Procedures• POST
REST
en
GENEXUS
http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?14573
![Page 23: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/23.jpg)
Consumir un servicio REST
• HTTPClient Data Type• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?6932
• Método ToJson / FromJson• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?10670
• Método ToXML / FromXML• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?8789• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?8788
![Page 24: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/24.jpg)
REST
en
GENEXUS
Lista de Entidades
![Page 25: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/25.jpg)
REST
en
GENEXUS
• Lista de Entidades / Entidad por PK
![Page 26: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/26.jpg)
Ejemplo: Exponer un Recurso para modificación
REST
en
GENEXUS
![Page 27: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/27.jpg)
Cliente de servicio RESTREST
En
GENEXUS
![Page 28: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/28.jpg)
Json 2 SDT
• Tools – Application Integration – Json Import
• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?22574
![Page 29: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/29.jpg)
TroubleShooting
• Tcptracehttp://www.tcptrace.org/• RestClienthttps://code.google.com/p/rest-client/
![Page 30: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/30.jpg)
HTTP
• Proveer• Procedure : Call Protocol = HTTP• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?7947
• Consumir• HttpClient, HttpRequest, HttpResponse data type. • http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?6932
![Page 31: Web services GeneXus Tilo](https://reader036.vdocuments.site/reader036/viewer/2022081415/55843bdbd8b42a77068b4eae/html5/thumbnails/31.jpg)
XML Schema Import
• Tools/Application integration/XML schema Import. (XSD)
• http://wiki.gxtechnical.com/commwiki/servlet/hwikibypageid?7200