25
Laboratory of Service Design and Engineering 2011/2012 Muhammad Imran: Lab Lectures for LSDE2011/2012 .

Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Laboratory of Service Design and Engineering2011/2012

Muhammad Imran: Lab Lectures for LSDE‐2011/2012 .

Page 2: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

JAX‐WS 2.0

Page 3: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

JAX‐WSPart 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.jws

Page 4: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Web Service

Page 5: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Using JAX‐WS 2.0 JAX‐WS 2.0 is extremely easy to useWe show you how to create a simple web service using JAX‐WS 2.0 with Java SE 6 technology.The first thing you need is a class with one or more methods that you wish to expose as a web service.

Page 6: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Creating Web Service

To expose these methods,  you must add two things: an import statement javax.jws.WebService package@WebService annotation at the beginning that tells the Java interpreter that you intend to publish the methods of this class as a web service.

Page 7: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Creating Web Service

Page 8: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Creating Web ServiceWith NetBeans 1.9.1JAX‐WS 2.0Java SE 6GlassFish Server

Page 9: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Create New Web App

Page 10: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Set Context Path & Server

Page 11: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Add new Web Service

Page 12: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Your Class

Page 13: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Deploying & TestingJust deploy from Netbeans from deploy option. Test your service through tester

http://localhost:8080/app‐name/service‐name?TesterCheck WSDL

http://localhost:8080/app‐name/service‐name?WSDL

Page 14: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Tester

Page 15: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

WSDL

Page 16: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Client Project

Page 17: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Create Service client

Page 18: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Give WSDL path

Page 19: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Stub generation

Page 20: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Main Class: Adding web service operation

Use ALT + INSERT   or  right click inside main class to insert codeChoose call web service operation

Page 21: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Select web service method

Page 22: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Web Service method

Page 23: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Let do this Exercise together

Page 24: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

ExerciseUse http://www.webservicex.net/Use there weather serviceCall the service using JAX‐WS methodologyAsk for Milan’s weather.

Page 25: Laboratory of Service Design and Engineering 2011/2012 · Using JAX‐WS 2.0 yJAX‐WS 2.0 is extremely easy to use yWe show you how to create a simple web service using JAX‐WS

Assignment‐3All requirements are the same as assignment‐2.Just provide same services using SOAP.You can use any method to implement SOAP which we learned in class. The use of JAX‐WS is recommended.

Deadline: 7th December 2011 (midnight)