Web servisu izstrade - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Web servisu izstrade

Description:

Title: PowerPoint Presentation Last modified by: AlinaD Created Date: 1/1/1601 12:00:00 AM Document presentation format: On-screen Show Other titles – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 29
Provided by: webk153
Category:

less

Transcript and Presenter's Notes

Title: Web servisu izstrade


1
Web servisu izstrade
JAX-WS
2
Ievads
  • JAX-WS Java API for XML Web Services
  • JAX-WS ir fundamentala Web servisu izstrades
    tehnologija
  • Java EE 5 un Java SE 6 sastavdala
  • JAX-WS 2.0 aizvietoja JAX-RPC
  • Pareja no RPC-style uz document-style web
    servisiem
  • Reference Implementation by GlassFish

3
Priekšvesture JAX-RPC
  • JAX-RPC Java API for XML-based RPC
  • Pirma specifikacijas versija (JAX-RPC 1.0) bija
    JSR-101 un ta bija izlaista 2002.gada junija
  • Fundamentalais merkis - vienkaršot sazinašanas
    starp Java un ne-Java platformam
  • Dod iespeju no Java programmas izsaukt Java Web
    servisu ar zinamu aprakstu (saskana ar servisa
    WSDL)

4
JAX-RPC modelis
  • JAX-RPC modelim, ir divas puses
  • Server-side programming model
  • Allows to develop Web service endpoints as Java
    objects or Enterprise JavaBeans, which run on the
    J2EE platform
  • Client-side programming model
  • Allows to access a remote Web service as if it
    were a local object, using methods that represent
    SOAP operations

5
Server-Side Programming
  • Two server-side programming models for creating
    Java EE Web service endpoints
  • POJO endpoints
  • EJB3 Stateless
  • Session Bean
  • endpoints

6
JAX-WS Annotations
  • Annotations play a critical role in JAX-WS 2.0
  • Annotations are used in mapping Java to WSDL and
    schema
  • Annotations are used in runtime to control how
    the JAX-WS runtime processes and responds to web
    service invocations
  • Annotations utilized by JAX-WS 2.0 are defined in
    separate JSRs
  • JSR 181 Web Services Metadata for the JavaTM
    Platform
  • JSR 222 JavaTM Architecture for XML Binding
    (JAXB) 2.0
  • JSR 224 JavaTM API for XML Web Services (JAX-WS)
    2.0
  • JSR 250 Common Annotations for the JavaTM
    Platform

7
Web Service Implementation
  • Write a POJO implementing the service
  • Add _at_WebService annotation to it
  • Optionally, inject a WebServiceContext
  • WebServiceContext makes it possible for a web
    service endpoint implementation class to access
    message context and security information relative
    to a request
  • Deploy the application
  • Point your clients at the WSDL
  • e.g. http//myserver/myapp/MyService?WSDL

8
Example HelloWebService
  • _at_WebService(name "HelloWebService")
  • _at_SOAPBinding(
  • style SOAPBinding.Style.DOCUMENT,
  • use SOAPBinding.Use.LITERAL,
  • parameterStyle
  • SOAPBinding.ParameterStyle.WRAPPED)
  • public class HelloWebService
  • _at_WebMethod
  • public String hello(_at_WebParam(name "name")
  • String name)
  • return "Welcome " name " !!!"

9
More Annotations
  • Web Services Metadata Annotations
  • _at_WebService
  • _at_WebMethod
  • _at_OneWay
  • _at_WebParam
  • _at_WebResult
  • JAX-WS Annotations
  • _at_RequestWrapper
  • _at_ResponseWrapper
  • _at_WebEndpoint
  • _at_WebFault
  • _at_WebServiceClient
  • _at_WebServiceRef

10
Web Service Deployment
  • To run Web service youll need to deploy it into
    web server with Java EE compliant web services
  • Java service endpoint usually is packaged as a
    web application in a WAR file
  • We will consider JBoss Application Server with
    JBoss Web Services (JBossWS)

11
JBoss Web Services
  • JBossWS is a JAX-WS compliant web service stack
    developed to be part of JBoss' Java EE 5 offering
  • At deployment time JBossWS will create services
    endpoints from annotated classes and publish the
    WSDL
  • At runtime SOAP requests are converted to JAVA
    invocations

12
JBossWS deploy-time run-time
13
Demo
  • Ir sagatavots demo projekts
  • http//java-eim.googlecode.com/svn/trunk/
  • java-eim-demo-jbossws
  • Pašlaik ir izveidoti divi vienkarši Web servisi
  • HelloWebService
  • CalculatorWebService
  • Instrukcijas pagaidam faila README.txt

14
JBossWS Console
  • http//localhost8080/jbossws/

15
Client-Side Programming
  • JAX-WS client programming models
  • Static ? Dynamic proxy client API
  • Dynamic ? Dispatch client API
  • Dynamic proxy client
  • Invokes a Web service based on a Service Endpoint
    Interface (SEI) which must be provided
  • Creating web service clients usually starts from
    the WSDL (WSDL first approach)
  • Special tools are used to generate client classes

16
Dispatch client API
  • Low level JAX-WS API to work at the XML message
    level or without any generated artifacts
  • Requires clients to construct messages or message
    payloads as XML
  • Requires an intimate knowledge of the desired
    message or payload structure

17
Client Side Generation (JBossWS)
  • JBossWS provide a tool for client side generation
    from WSDL
  • wsconsume
  • From ltJBOSS_HOMEgt/bin execute
  • wsconsume -k -p ltpackagegt ltpath_to_wsdlgt

18
Generated Files
  • HelloWebServiceService.java
  • Service factory
  • HelloWebService.java
  • Service Endpoint Interface
  • Hello.java
  • Custom data type for request
  • HelloResponse.java
  • Custom data type for response
  • ObjectFactory.java
  • JAXB XML Registry
  • package-info.java
  • Holder for JAXB package annotations

19
Client Code
  • import xxx.generated.hello.HelloWebService
  • import xxx.generated.hello.HelloWebServiceService
  • public class HelloWebServiceClient
  • public static void main(String args)
  • HelloWebServiceService helloFactory
  • new HelloWebServiceService()
  • HelloWebService helloService
    helloFactory.getPort(HelloWebService.class)
  • String response helloService.hello("WebService
    Client")

20
Web Service Invocation
  1. A Java program invokes a method on a stub (local
    object representing the remote service)
  2. The stub invokes routines in the JAX-WS runtime
    system
  3. The runtime system converts the remote method
    invocation into a SOAP message
  4. The runtime system transmits the message as an
    HTTP request

21
Server-Side Debugging (JBoss)
  • Add or un-comment the following line in run.bat
  • rem JPDA options. Uncomment and modify as
  • rem appropriate to enable remote debugging.
  • set JAVA_OPTS-Xdebug -Xrunjdwptransportdt_socke
    t,
  • address8787,servery,suspendn JAVA_OPTS
  • 2. Create new Remote Java Application debug
    configuration in Eclipse ? Run ? Open Debug
    Dialog

22
Server-Side Debugging (JBoss)
23
Server-Side Debugging (JBoss)
  1. Start JBoss
  2. Launch Debug configuration in Eclipse

24
Server-Side Debugging (JBoss)
  • Add breakpoint, e.g. to Web service code and run
    client
  • Server will stop at breakpoint

25
Server-Side Debugging (JBoss)
26
Nobeigums
  • Tas bija tikai iss ievads..!
  • Web servisu temats ir daudz plašaks...

27
References
  • JAX-WS Annotations
  • https//jax-ws.dev.java.net/jax-ws-ea3/docs/annot
    ations.html
  • JBossWS Home
  • http//labs.jboss.com/jbossws/
  • JBossWS Wiki
  • http//jbws.dyndns.org/mediawiki/index.php?title
    JBossWS

28
References
  • JAX-WS Reference Implementation by GlassFish
  • https//jax-ws.dev.java.net/
  • JAX-WS Specification (JSR 224) http//jcp.org/en/j
    sr/detail?id224
  • Presentation about JAX-WS http//gceclub.sun.com.c
    n/java_one_online/2006/TS-1194/TS-1194.pdf
Write a Comment
User Comments (0)
About PowerShow.com