web servisu izstr de n.
Skip this Video
Loading SlideShow in 5 Seconds..
Web servisu izstrāde PowerPoint Presentation
Download Presentation
Web servisu izstrāde

Loading in 2 Seconds...

play fullscreen
1 / 28

Web servisu izstrāde - PowerPoint PPT Presentation

  • Uploaded on

Web servisu izstrāde. JAX-WS. Ievads. JAX-WS = Java API for XML Web Services JAX-WS ir fundamentāla Web servisu izstrādes tehnoloģija Java EE 5 un Java SE 6 sastāvdaļa JAX-WS 2.0 aizvietoja JAX-RPC Pāreja no RPC-style uz document-style web servisiem

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Web servisu izstrāde

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
  • JAX-WS = Java API for XML Web Services
  • JAX-WS ir fundamentāla Web servisu izstrādes tehnoloģija
  • Java EE 5 un Java SE 6 sastāvdaļa
  • JAX-WS 2.0 aizvietoja JAX-RPC
    • Pāreja no RPC-style uz document-style web servisiem
  • Reference Implementation – by GlassFish
priek v sture jax rpc
Priekšvēsture: JAX-RPC
  • JAX-RPC = Java API for XML-based RPC
  • Pirmā specifikācijas versija (JAX-RPC 1.0) bija JSR-101 un tā bija izlaista 2002.gada jūnijā
  • Fundamentālais mērķis - vienkāršot sazināšanas starp Java un ne-Java platformām
  • Dod iespēju no Java programmas izsaukt Java Web servisu ar zināmu aprakstu (saskaņā ar servisa WSDL)
jax rpc modelis
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
server side programming
Server-Side Programming
  • Two server-side programming models for creating Java EE Web service endpoints:
    • POJO endpoints
    • EJB3 Stateless

Session Bean


jax ws annotations
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
web service implementation
Web Service Implementation
  • Write a POJO implementing the service
  • Add @WebService annotation to it
  • Optionally, inject a WebServiceContext
    • WebServiceContextmakes it possible for a web serviceendpoint implementation class to access messagecontext and security information relative to a request
  • Deploy the application
  • Point your clients at the WSDL
    • e.g. http://myserver/myapp/MyService?WSDL
example hellowebservice
Example: HelloWebService

@WebService(name = "HelloWebService")


style = SOAPBinding.Style.DOCUMENT,

use = SOAPBinding.Use.LITERAL,

parameterStyle =


public class HelloWebService {


public String hello(@WebParam(name = "name")

String name){

return "Welcome " + name + " !!!";



more annotations
More Annotations
  • Web Services Metadata Annotations
    • @WebService
    • @WebMethod
    • @OneWay
    • @WebParam
    • @WebResult
  • JAX-WS Annotations
    • @RequestWrapper
    • @ResponseWrapper
    • @WebEndpoint
    • @WebFault
    • @WebServiceClient
    • @WebServiceRef
web service deployment
Web Service Deployment
  • To run Web service you’ll 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 withJBoss Web Services (JBossWS)
jboss web services
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
  • Ir sagatavots demo projekts:



  • Pašlaik ir izveidoti divi vienkārši Web servisi:
    • HelloWebService
    • CalculatorWebService
  • Instrukcijas pagaidām failā README.txt
jbossws console
JBossWS Console


client side programming
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
dispatch client api
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
client side generation jbossws
Client Side Generation (JBossWS)
  • JBossWS provide a tool for client side generation from WSDL


  • From <JBOSS_HOME>/bin execute:

wsconsume -k -p <package> <path_to_wsdl>

generated files
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
client code
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("WebServiceClient");



web service invocation
Web Service Invocation
  • A Java program invokes a method on a stub (local object representing the remote service)
  • The stub invokes routines in the JAX-WS runtime system
  • The runtime system converts the remote method invocation into a SOAP message
  • The runtime system transmits the message as an HTTP request
server side debugging jboss
Server-Side Debugging (JBoss)
  • Add or un-comment the following line in run.bat

rem JPDA options. Uncomment and modify as

rem appropriateto enable remote debugging.

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,

address=8787,server=y,suspend=n %JAVA_OPTS%

2. Create new “Remote Java Application” debug configuration in Eclipse: Run  Open Debug Dialog

server side debugging jboss2
Server-Side Debugging (JBoss)
  • Start JBoss
  • Launch Debug configuration in Eclipse
server side debugging jboss3
Server-Side Debugging (JBoss)
  • Add breakpoint, e.g. to Web service code and run client
  • Server will stop at breakpoint

Tas bija tikai īss ievads..!

Web servisu temats ir daudz plašāks...

  • JAX-WS Annotations


  • JBossWS Home


  • JBossWS Wiki


  • JAX-WS Reference Implementation by GlassFish


  • JAX-WS Specification (JSR 224) http://jcp.org/en/jsr/detail?id=224
  • Presentation about JAX-WS http://gceclub.sun.com.cn/java_one_online/2006/TS-1194/TS-1194.pdf