DOC PREVIEW
CMU ISM 95702 - JDK 6 Web Services

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

JDK 6 Web ServicesJAX-WS 2.0Writing A Web ServicePowerPoint PresentationCompile The ServicePublish the ServiceGenerate Stub CodeWrite the ClientCompile & Run the ClientServerCounter is a Singleton195-702 OCTMaster of Information System ManagementJDK 6 Web ServicesWeek 3: JAX-WS 2.0295-702 OCTMaster of Information System ManagementJAX-WS 2.0 •Part of Java EE.•New in Java SE 6.•API stack for web services.•Replaces JAX-RPC.•New API’s: JAX-WS, SAAJ, Web Service metadata•New packages: javax.xml.ws, javax.xml.soap,javax.jws395-702 OCTMaster of Information System ManagementWriting A Web Servicepackage loanservice;import javax.jws.WebService;import javax.jws.WebMethod;import javax.xml.ws.Endpoint;@WebServicepublic class LoanApprover { @WebMethod public boolean approve(String name) { return name.equals("Mike"); }495-702 OCTMaster of Information System Managementpublic static void main(String[] args){ LoanApprover la = new LoanApprover(); Endpoint endpoint = Endpoint.publish( "http://localhost:8080/loanapprover", la); }}595-702 OCTMaster of Information System ManagementCompile The ServiceCreate a myservice directory.From the directory just above loanservice, run Java’sAnnotation Processing Tool (APT):C:\>apt -d myservice loanservice/LoanApprover.javaThis populates a directory named myservice.The directory holds the compiled package as wellas a new directory (package) called jaxws.The new jaxws package holds classes associated withthe parameters to and from each web service method.Use the -s switch to generate the source code.695-702 OCTMaster of Information System ManagementPublish the ServiceFrom a directory just above myservice:C:\>java -cp myservice loanservice/LoanApproverTo view the WSDL, visit the service with a browser at http://localhost:8080/loanapprover?wsdl795-702 OCTMaster of Information System ManagementGenerate Stub CodeMake a client directory.C:\>wsimport –p client –keep http://localhost:8080/loanapprover?wsdlThis populates the client subdirectory with .classand .java files.895-702 OCTMaster of Information System ManagementWrite the Clientpackage 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("Approved"); else System.out.println("Not approved");}}995-702 OCTMaster of Information System ManagementCompile & Run the ClientC:\>javac –cp . client/ApproverClient.javaC:\>java -cp . client/ApproverClientApprovedDemo files under :mm6/www/95-843/JDK6_WebServices/Demo1095-702 OCTMaster of Information System ManagementServerCounter is a Singleton@WebServicepublic class ServerCounter { int ctr = 0; public int getCtr() { ctr++; return ctr; }} What happens?A single objectholds the countand every clientshares it. Eachvisit generates a new updated


View Full Document

CMU ISM 95702 - JDK 6 Web Services

Documents in this Course
Homework

Homework

12 pages

Lecture

Lecture

25 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Exam

Exam

11 pages

Homework

Homework

16 pages

Homework

Homework

38 pages

lecture

lecture

38 pages

review

review

7 pages

lecture

lecture

18 pages

review

review

8 pages

Chapter2

Chapter2

32 pages

Lecture 4

Lecture 4

47 pages

Lecture

Lecture

22 pages

Naming

Naming

26 pages

lecture

lecture

34 pages

lecture

lecture

42 pages

lecture

lecture

112 pages

Lecture

Lecture

33 pages

Axis

Axis

43 pages

lecture

lecture

32 pages

review

review

17 pages

Lecture

Lecture

53 pages

Lecture

Lecture

80 pages

Lab

Lab

14 pages

Load more
Download JDK 6 Web Services
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view JDK 6 Web Services and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view JDK 6 Web Services 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?