web services 4 java
TRANSCRIPT
![Page 1: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/1.jpg)
WebServices
Intro
![Page 2: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/2.jpg)
2
IntroducciónWebServiceCaracterísticasTipos de Web ServiceJAX-WSJAX-RS
QuickStart SOAPRequemientosAmbienteGlassFish Metro
JAX-WSWSDLEndpointJava ClienteSOAP
WS-IQuickStart Rest
RequerimientosAmbienteJersey
JAX-RSWADLJSONEndpoint Java ClienteManejo de ErroresSeguridadBestPractices
PruebasSOAPUISOAPServiceRestService
Temario
WebService
![Page 3: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/3.jpg)
WS Intro¿Qué es un WebService?
Como su nombre lo indica, un servicio web es un tipo de “webified application” (Habilitado para la web), es decir, una aplicación que generalmente se entrega a través de HTTP (Hyper Text Transport Protocol).
Un servicio web es una aplicación distribuida cuyos componentes se pueden implementar y ejecutar en distintos tipos de dispositivos.
Los servicios Web se pueden dividir a grandes rasgos en dos grupos, SOAP-based y REST-style.
3
cmp WebServ ice
Hello
HelloWebService
HelloWSEJB
HelloService
![Page 4: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/4.jpg)
WS Intro
Principales CaracterísticasEstándares abiertos
HTTPXMLSOAP
InteroperabilidadWS-I Su objetivo es fomentar y promover la Interoperabilidad de Servicios Web (Web Services Interoperability - WS-I) sobrecualquier plataforma, sobre aplicaciones y sobre lenguajes de programación.
SOA (Arquitectura Orientada a Servicios)
4
GET /index.html HTTP/1.1 Host: www.example.com
![Page 5: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/5.jpg)
SOAP
Arquitectura de MensajesUn mensaje SOAP es una transmisión unidireccional de un emisor a un receptorEl MEP (message exchange pattern) de solicitud / respuesta en un SOAP WS es una breve conversación en la que una solicitud inicia la conversión y la respuesta concluye la conversación.
5
Primitivas
Variable/Clases
Métodos
![Page 6: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/6.jpg)
6
Tecnología/SOAP
URL
![Page 7: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/7.jpg)
WS Intro
SOAP ServiceSe encuentra sobre un protocolo SOA (Service Oriented Architecture), los servicios web juegan un papel central en SOA para el diseño y desarrollo de software.
WSDL (Web Services Description Language)
XML Types (Extensible Markup Language)
SOAP (Simple Object Access Protocol)
Rest ServiceWADL (Web Application Description Language)
JSON (JavaScript Object Notation)
HTTP (Métodos nativos Hypertext Transfer Protocol)
7
![Page 8: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/8.jpg)
REST Service, (REpresentational State Transfer), Roy Fielding creó el acrónimo en su tesis de Doctorado para describir un estilo arquitectónico en el diseño de servicios web.
Características:No cuenta con normasPocas herramientas Escasas bibliotecas de softwareEl REST se ve a menudo como un antídoto
contra la complejidad progresiva de los servicios web basados en SOAP.
REST necesita invocaciones del cliente para realizarsus operaciones por medio de HTTP, el cual cuenta con sus propios métodos.
Sitio Ejemplo: http://www.baseball-reference.com/
8
WS Intro
![Page 9: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/9.jpg)
REST Service
Metodos HTTP y operaciones CRUD (Create, Read, Update Delete):
9
Respuestas:
• 404 .- El recurso No fue encontrado
• 200 .- La solicitud fue manejada con éxito
Los navegadores modernos sólo generan peticiones GET y POST
![Page 10: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/10.jpg)
REST Service
WADLTrata de ser la contraparte del WSDL, lo cual no es oficial, solo es una iniciativa.
SOAP Services
REST Services
10
WSDL
WADL
![Page 11: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/11.jpg)
WS Intro
JAX-WS (proporciona la base de proyecto Metro, en el interior de la comunidad GlassFish)
Especificación para construir SOAP Service.Incluida en Java 6Parte de Java EE 5 / 6RI Metro (pila de servicios web de alto rendimiento, ampliable y fácil de utilizar)
WSIT Tango (Web Services Interoperability Technologies)
Uso de Anotaciones
11
![Page 12: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/12.jpg)
WS Intro
JAX-WS
12
Cliente Servidor
JAX-WS Runtime
JAX-WS Runtime
SOAP Request
![Page 13: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/13.jpg)
WS Intro
JAX-WS
13
Java @
AppCLI
SOAP
![Page 14: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/14.jpg)
WS Intro
JAX-WS ImplementacionesGlassFish Metro (RI)
http://metro.java.net/Apache Axis2
http://axis.apache.org/axis/Apache CXF
http://cxf.apache.org/Spring Web Services**
http://static.springsource.org/spring-ws/sites/2.0/Jboss WS
http://www.jboss.org/jbosswsJavaSE 6
14
![Page 15: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/15.jpg)
WS Intro
JAX-RSEspecificación para construir Rest Service.HTTP/ URIParte de Java EE 6RI Jersey (implementación de referencia)
Uso de Anotaciones
15
![Page 16: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/16.jpg)
WS Intro
JAX-RS
Client Rest
16
Cliente Servidor
JAX-RS Runtime
JAX-RS Runtime
HTTP Request
URL
![Page 17: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/17.jpg)
WS Intro
JAX-RSClient
17
URL
JSON
![Page 18: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/18.jpg)
WS Intro
JAX-RSServidor
18
URL
HTTP Method Contenido a Generar
![Page 19: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/19.jpg)
WS Intro
JAX-RS ImplementacionesJersey (RI)
http://jersey.java.net/Apache CXF
http://cxf.apache.org/RestEasy
http://www.jboss.org/resteasy/Apache HttpComponents*
http://hc.apache.org/Java SE*
java.net
19
![Page 20: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/20.jpg)
WS Intro
SOAPServices RestServices
20
VS
![Page 21: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/21.jpg)
No cuenta con normasPocas herramientas Escasas bibliotecas de softwareWADL
un protocolo SOAWSDLXML Types
21
RestServices SOAPServices
![Page 22: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/22.jpg)
WebServices
SOAP QuickStart
![Page 23: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/23.jpg)
SOAP QuickStart
RequerimientosJDK6**JAVA_HOMEMyEclipseApplicationServer V5
Glassfish v2***WebLogic 11gJboss 6
OracleXEMaterial Curso
\\smprodtq2\software\WebService
23
![Page 24: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/24.jpg)
SOAP QuickStart
Lista de pasos a realizarInstalar JDK 6, EclipseDescomprimir Application Server C:\bin\
Cambiar JDK C:\bin\glassfishV2\config\asenv.bat Configurar AS+EclipseImportar ProyectosIniciar AS
C:\bin\glassfishV2\bin\>asadmin start-domain MyEclipseusu:admin pwd:adminadmin
Modificar ConnectionPool : CambryPoolusu:hr pwd:je.zamora
URL: jdbc:oracle:thin:@ 127.0.0.1:1521:orcl
Revisar los elementos que integran la aplicación:CambryAdapterSoapConsola Administración AS http://localhost:4848
24
![Page 25: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/25.jpg)
SOAP QuickStart
Consola Administración AShttp://localhost:4848/
25
WebService
DescripciónServicio
Cliente Pruebas
![Page 26: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/26.jpg)
SOAP QuickStart
WSDL - HelloSoapServicehttp://localhost:8080/HelloSoapServiceService/HelloSoapService?wsdl
26
![Page 27: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/27.jpg)
SOAP QuickStart
WSDL - HelloSoapServicehttp://localhost:8080/HelloSoapServiceService/HelloSoapService?wsdl
27
![Page 28: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/28.jpg)
SOAP QuickStart
Cliente - HelloSoapServicehttp://localhost:8080/HelloSoapServiceService/HelloSoapService?tester
28
Operaciones (Metodos)
![Page 29: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/29.jpg)
SOAP QuickStart
Cliente - HelloSoapServicehttp://localhost:8080/HelloSoapServiceService/HelloSoapService?tester
29
![Page 30: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/30.jpg)
WebService
WSDL
30
![Page 31: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/31.jpg)
WSDL
Lenguaje de Descripción del Web ServiceContrato entre un servicio y sus consumidoresIndispensable para crear un Cliente del ServicioXML
31
http://www.soamag.com/I27/0309-3.php
![Page 32: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/32.jpg)
WSDL
Partes del Contratotypes
Proporciona la definición de los tipos de datos bajo algún esquema de definición de datos, por ejemplo XSD.Pueden ser importados de otro documento de definiciones
32
![Page 33: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/33.jpg)
WSDL
Partes del ContratoMessages
Mensajes que implementa el Servicio. Construidos a partir de tipos de datos definidos en la sección anterior o importados.Definición de Variables.
33
![Page 34: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/34.jpg)
WSDL
Partes del ContratoportType
Operaciones nombradas del Servicio. Cada operaciones tiene uno o mas mensajes.@WebMethod Java Interface
Java Métodos -> Operaciones
34
Interface
Métodos
![Page 35: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/35.jpg)
WSDL
Partes del Contratobinding
Es donde enlazamos la abstracción (WSDL) con la implementación. Proporciona detalles concretos del servicio.El protocolo (aplicativo) de transporte será utilizado para mandar mensajes SOAP. http smtpEstilo del servicio: document RPC (@SOAPBinding)
(Remote Procedure Call, Llamada a Procedimiento Remoto)
Formato de datos utilizado en los mensajes SOAP literal encoded
35
![Page 36: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/36.jpg)
WSDL
Partes del ContratoService
Define los endpoint donde el servicio se despachara.URL
36
![Page 37: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/37.jpg)
WSDL
BindingWS-I
documentliteral
37
style use
document literal
document encoded
rpc literal
rpc encoded
![Page 38: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/38.jpg)
WSDLRPC/encodedRPC/literalDocument/literal WDocument/literal
38
![Page 39: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/39.jpg)
WSDL
BindingRPC -> JAX-RSNO WS-INo existe definición de tiposNO SOA
39
NO Types
Incrustados
![Page 40: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/40.jpg)
WSDL
Java ClienteWSDLhttp://localhost:8080/cambry/HelloSoapServiceService?wsdl
C:\WS\MyEclipse\TestSoap>wsimport -s examples -p mx.ids.cambry.adapter.soap http://localhost:8080/cambry/HelloSoapServiceService?wsdl
40
![Page 41: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/41.jpg)
WebServices
Endpoint
41
![Page 42: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/42.jpg)
WS Endpoint
Implementacion Service Endpoint Interface (SEI)
Java InterfaceService Implementation Bean (SIB)
WebContainerPOJO
EJB Container Session Stateless
42
WEBContainer
EJBContainer
![Page 43: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/43.jpg)
WS Endpoint
Service Endpoint Interface (SEI)
43
Java Interface Operaciones
WS-I
![Page 44: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/44.jpg)
WS Endpoint
Service Endpoint BeanPOJO
http://localhost:8080/cambry/HelloSoapServiceImplService?wsdl
44
Java Interface
WebContext Class SEB Name + “Service”HelloSoapServiceImpl + “Service”
![Page 45: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/45.jpg)
WS Endpoint
Service Endpoint BeanEJB Session stateless
http://localhost:8080/HelloSoapServiceImplService/HelloSoapServiceImpl?wsdl
45
Java Interface
![Page 46: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/46.jpg)
WS Endpoint
Service Endpoint BeanEJB Session stateless V2
46
![Page 47: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/47.jpg)
WS Endpoint
Service Endpoint BeanEJB Session stateless V2
47
![Page 48: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/48.jpg)
WS Endpoint
SEB EJBWS-*TransaccionalidadSeguridadThread safetyIntances pooling
SEB POJOJava Servlet
48
![Page 49: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/49.jpg)
WS Endpoint
Manejo de ErroresJava Exception & SOAP Message Fault
49
![Page 50: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/50.jpg)
WS Endpoint
Manejo de ErroresJava Exception & SOAP Message Fault
50
![Page 51: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/51.jpg)
WebServices
Clientes
51
![Page 52: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/52.jpg)
WS Clientes
URL del WSDLhttp://localhost:8080/HelloSoapService/HelloService?wsdl
Archivo WSDL
52
![Page 53: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/53.jpg)
WS Clientes
Desde la Línea de Comandos
53
![Page 54: Web Services 4 Java](https://reader033.vdocuments.net/reader033/viewer/2022061107/544a9b63b1af9f03108b49ae/html5/thumbnails/54.jpg)
54
PREGUNTAS