Service Oriented Architecture - PowerPoint PPT Presentation

About This Presentation
Title:

Service Oriented Architecture

Description:

Service Oriented Architecture Lecture 2: JAX-WS 2.0 JAX-WS 2.0 Part of Java EE. New in Java SE 6. API stack for web services. Replaces JAX-RPC. – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 10
Provided by: Office2770
Category:

less

Transcript and Presenter's Notes

Title: Service Oriented Architecture


1
Service Oriented Architecture
  • Lecture 2 JAX-WS 2.0

2
JAX-WS 2.0
  • Part of Java EE.
  • New in Java SE 6.
  • API stack for web services.
  • Replaces JAX-RPC.
  • New APIs
  • JAX-WS, SAAJ, Web Service metadata
  • New packages
  • javax.xml.ws, javax.xml.soap,javax.jws

3
Writing A Web Service
  • package loanservice
  • import javax.jws.WebService
  • import javax.jws.WebMethod
  • import javax.xml.ws.Endpoint
  • _at_WebService
  • public class LoanApprover
  • _at_WebMethod
  • public boolean approve(String name)
  • return name.equals("Mike")

4
  • public static void main(String args)
  • LoanApprover la new LoanApprover()
  • Endpoint endpoint
  • Endpoint.publish(
  • "http//localhost8080/loanapprover",
  • la)

5
Compile The Service
  • Create a myservice directory.
  • From the directory just above loanservice, run
    Javas
  • Annotation Processing Tool (APT)
  • C\gtapt -d myservice loanservice/LoanApprover.java
  • This populates a directory named myservice.
  • If you copy these commands from the slides you
    may
  • have to retype those strings containing the -
    character.

6
Publish the Service
  • From a directory just above myservice
  • C\gtjava -cp myservice loanservice/LoanApprover
  • To view the WSDL, visit the service with a
    browser at
  • http//localhost8080/loanapprover?wsdl

7
Generate Stub Code
  • Make a client directory.
  • C\gtwsimport p client keep http//localhost8080
    /loanapprover?wsdl
  • This populates the client subdirectory with
    .class
  • and .java files.

8
Write the Client
  • package client
  • class ApproverClient
  • public static void main(String args)
  • LoanApproverService service new
    LoanApproverService()
  • LoanApprover approverProxy
    service.getLoanApproverPort()
  • boolean result approverProxy.approve
    ("Mike")
  • if(result) System.out.println("Approve
    d")
  • else System.out.println("Not
    approved")

9
Compile Run the Client
  • C\gtjavac cp . client/ApproverClient.java
  • C\gtjava -cp . client/ApproverClient
  • Approved
Write a Comment
User Comments (0)
About PowerShow.com