Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Programming Java Web Services using the Java TM API for XMLWeb Services (JAX-WS) Bill Champlin UCCS / CS526 Spring ‘09.

Similar presentations


Presentation on theme: "Intro to Programming Java Web Services using the Java TM API for XMLWeb Services (JAX-WS) Bill Champlin UCCS / CS526 Spring ‘09."— Presentation transcript:

1 Intro to Programming Java Web Services using the Java TM API for XMLWeb Services (JAX-WS) Bill Champlin UCCS / CS526 Spring ‘09

2 2 Agenda Project Description / Purpose Overview of JAX-WS and Java Web Services Programming Steps Advantages / Disadvantages References

3 3 Project Description The Purpose of this Project is to Learn: –Capabilities of the JAX-WS API –Steps to Programming a Service and a Client –SOAP XML Messaging –Role of JAX-WS in Java Web Services

4 4 JAX-WS Overview Used to Build Java Web Services / Clients Uses SOAP Messages (also REST Msg Protocol) –Over HTTP (also SMTP) Abstracts SOAP Messages from Developer –Doesn’t Have to Write Code to Parse Messages NOT ALWAYS TRUE –JAX-B Converts Java types to / from SOAP Messages Supports RPC or Document Messaging Styles –RPC - Simple Types i.e. xsd:long, xsd: byte, etc –Document - Complex Types by Creating new XML Schemas Supports Asynchronous Requests via Thread Pools Faults can be Thrown back to Clients Can Insert Binary Data as the Payload or as a SOAP Attachment

5 5 Java Web Services

6 6 Basic Programming Steps [2] 1.Code & Compile Annotated Java Web Service: - Service Endpoint Interface (SEI) (Optional) - Service Implementation Bean (SIB) Class 2.Run “wsgen” to Create “Artifacts” - Java Types for Marshaling to / from XML Types 3.Deploy the Services using Endpoint. publish() (or High Level Tools i.e. Metro, Glass Fish, etc.) --> Creates the WSDL - Web Service Definition Language Document (aka “Whiz-Dull”) - XML file that Defines the Contract between SEI and Clients - WSDL can be found at: http://127.0.0.1:8888/teams?wsdl 4.Run “wsimport” to Create a Proxy SEI using WSDL 5.Code Client Against Proxy SEI 6.Execute Client (Optional – Create Service Side or Client Side Message Handlers)

7 Data Flow 7 HandlersHandlers HandlersHandlers HTTPHTTP CLIENT SERVICE

8 8 JAX-WS Sample Service [1] // Service @WebService public class Teams { private TeamsUtility utils; public Teams() { utils = new TeamsUtility(); utils.make_test_teams();} @WebMethod public Team getTeam(String name) { return utils.getTeam(name); } @WebMethod public List getTeams() { return utils.getTeams(); }}

9 JAX-WS Sample Client [1] // Client class TeamClient { public static void main(String[ ] args) { TeamsService service = new TeamsService(); Teams port = service.getTeamsPort(); List teams = port.getTeams(); for (Team team : teams) { System.out.println("Team: " + team.getName() + " (roster count: " + team.getRosterCount() +")"); for (Player player : team.getPlayers()) System.out.println(" Player: " + player.getNickname());

10 10 Advantages / Disadvantages Advantages: –Easy to Create Simple Interoperable Services –Protocol Hidden from Developer (but Available) –Java Threading allows Asynchronous Services –Faults (exceptions) can be Propagated Back to Client Disadvantages: –Rapidly Changing s/w Versions / Tools –Complex to Modify SOAP messages using API –Binary Attachments Require Modifying WSDL

11 11 References Project Website: http://cs.uccs.edu/~wchampli/cs526/project.html http://cs.uccs.edu/~wchampli/cs526/project.html Resources: 1.Java Web Services: Up and Running, by Martin Kalin. Copyright 2009 Martin Kalin, 978-0-596-52112-7 2.Sun Microsystems. The Java Web Services Tutorial for Java Web Services Developer’s Pack, v2.0 February 17, http://java.sun.com/webservices/tutorial.htmlhttp://java.sun.com/webservices/tutorial.html 3.Core Java Volume 2, Advanced Features, Cay S. Horstmann and Gary Cornell, Sun Microsystems Press, Prentice Hall, Copyright 2008, 978-0132354790, pgs 871-882. 4.Create JAX-WS Service in 5 Minutes (Tutorial), Alexander Ananiev & MyArch, http://myarch.com/create-jax-ws-service-in-5-minutes, Copyright © 2002-2006Alexander AnanievMyArch http://myarch.com/create-jax-ws-service-in-5-minutes 5.JAX-WS Tutorial http://www.javacoda.com/blog/?p=22http://www.javacoda.com/blog/?p=22 6.stackoverflow Q&A site. http://stackoverflow.com/questions/100993/rmi-vs-web- services-whats-best-for-java2java-remotinghttp://stackoverflow.com/questions/100993/rmi-vs-web- services-whats-best-for-java2java-remoting


Download ppt "Intro to Programming Java Web Services using the Java TM API for XMLWeb Services (JAX-WS) Bill Champlin UCCS / CS526 Spring ‘09."

Similar presentations


Ads by Google