Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presentation: Advanced AXIS: Deployment Descriptors and Advanced Types.

Similar presentations


Presentation on theme: "Presentation: Advanced AXIS: Deployment Descriptors and Advanced Types."— Presentation transcript:

1 Presentation: Advanced AXIS: Deployment Descriptors and Advanced Types

2 Ingeniørhøjskolen i Århus Slide 2 af 14 Outline So far with AXIS –Installation of Apache Tomcat and AXIS –Easy deployment of.java with.jws –Using Dynamic Call Interface for the Client to.jws Rather tedious work – and pretty error-prone –WSDL2Java Client generation This time –Use of.wsdd deployment files in AXIS (server specific) –Types allowed in Java/WSDL mappings (client/server) –Use of Arrays and Objects (client/server) –Custom Objets (client/server) –Use of the WSDL2Java stubgeneration tool (client) –Scope (client/server)

3 Ingeniørhøjskolen i Århus Slide 3 af 14 Using Axis Web Service Deployment Descriptor Easy to use.jws –But not nice deployment –How to undeploy –Problems with accessing outside classes –Not possible to use custom objects Alternative: Using the deployment tool in Axis –% java org.apache.axis.client.AdminClient deploy.wsdd

4 Ingeniørhøjskolen i Århus Slide 4 af 14 Using Axis Web Service Deployment Descriptor II Web Service Deployment Descriptor (.wsdd) is XML for defining characteristics of a Web service –The service name and the provider –The (packaged) class that provides the service –Which of the class methods are to be exposed (all or limited)

5 Ingeniørhøjskolen i Århus Slide 5 af 14 Using Axis Web Service Deployment Descriptor III Web service scope specifies the lifetime/management of the service class. –Specify scope of the Web service (request, application or session) in wsdd –request - is the default scope; each request causes a new service object to be created to handle the request –session - conceptually, all requests by a single client are handled by a single object (implemented with cookies) –application - a singleton web service. A single object serves all clients. More on scope later

6 Ingeniørhøjskolen i Århus Slide 6 af 14 Parameter Types for Web Services and Clients in AXIS The primitive types are mapped as shown below: XSD Type --> Java Type xsd:base64Binary --> byte[] xsd:boolean --> boolean xsd:byte --> byte xsd:dateTime --> java.util.Calendar xsd:decimal --> java.math.BigDecimal xsd:double --> double xsd:float --> float xsd:hexBinary --> byte[] xsd:int --> int xsd:integer --> java.math.BigInteger xsd:long --> long xsd:QName --> javax.xml.namespace.QName xsd:short --> short xsd:string --> java.lang.String These types can be used as either parameter or return types.

7 Ingeniørhøjskolen i Århus Slide 7 af 14 Objects Allowed objects are: –Objets listed above –Objects that conforms to the Java Bean Standard Custom objects – rolling your own –Normally one would like to use own objects as parameters and return values –This may be done using the BeanSerializer –Beans MUST conform to the Java Bean Standard This means empty constructor and accessor (getter/setter) methods –More on this later Collections SHOULD NOT BE USED if interoperability is needed (e.g. with C# og C++) –Instead use regular Arrays (Object[] and typecast)

8 Ingeniørhøjskolen i Århus Slide 8 af 14 Using Custom Objects Axis supports passing user-defined class objects that are Java Beans –get and set methods are defined for every class attribute –the class is Serializable Marshalling and Unmarshalling parameters and returns Suppose a Web Service returns a user-defined SomeClass object. –On the server, deploy with a wsdd element associating the user-defined class (SomeClass ) with the Axis provided BeanService as: – On the client side, WSDL2Java creates a BeanService. SomeObject class –The wsdl for the corresponding Web Service includes xml for SomeClass. –The proxy unmarshals a returned Message object to a BeanService. SomeClass object.

9 Ingeniørhøjskolen i Århus Slide 9 af 14 Example WSDD TV-Program Web service (TVPSService.class): Java Server C# Client (Pocket PC.NET CF) Java Client (UNIX, LINUX, Windows) Key elements: Package of service = tvps Class of service = tvps.TVPSService Allowed methods = all (*) Custom class (return parameter) = tvps.Programme

10 Ingeniørhøjskolen i Århus Slide 10 af 14 Client side – using WSDL2Java The deployment is purely server side Lets now take a look at the client side If we would like to generate Client proxy stubs for a WSDL service – we could use: –C:\dev-axis\java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/Calculator.jws?wsdl -p calc Which would generate a package ”calc” containing all the Proxy code needed for building a Client

11 Ingeniørhøjskolen i Århus Slide 11 af 14 Result of WSDL2Java WSDL clauseJava class(es) generated For each entry in the type sectionA java class A holder if this type is used as an inout/out parameter For each portTypeA java interface For each bindingA stub class For each serviceA service interface A service implementation (the locator)

12 Ingeniørhøjskolen i Århus Slide 12 af 14 Building a Client package hello; public class HelloWorldClient { public static void main (String args[]) throws Exception { // Make a service HelloWorldService service = new HelloWorldServiceLocator(); //Now use the service to get a stub which implements the SDI HelloWorld stub = (HelloWorld) service.getHelloWorld(); String text = stub.getHelloWorldMessage("Test af OO indpakning"); System.out.println(”Recieved from server: "+text); } Lets start by generating the Clients stub given the WSDL (-p = destination package = hello): java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/HelloWorld.jws?wsdl –p hello

13 Ingeniørhøjskolen i Århus Slide 13 af 14 Axis Life-Cycle Management for Web Services Web service scope specifies the lifetime/management of the service class. –request - has the same effect as if a new service object is created to handle each method call. –Request is the default scope - provides scalability in high- capacity load-balanced applications. Connections and/or server objects can be pooled. –session - conceptually, all requests from a single client are handled by a single object. Implemented with cookies, and requires client support. –application - a singleton web service. A single object serves all clients. Using application scope for a Java Web Service and Client –The deploy.wsdd specifies application scope for the Web Service

14 Ingeniørhøjskolen i Århus Slide 14 af 14 Using Session Scope with Axis Using the session scope for a Java Web Service and Client –For example, count all calls made to a service by a single client. –Each client has its own call count -- in effect, has its own service object. –The deploy.wsdd specifies session scope for the Web Service For session scope to work, the web service client must also specify a session mechanism –In C# as: tcs.CookieContainer = new System.Net.CookieContainer(); –Java Proxy as: ((MyWSServiceLocator)tcs).setMaintainSession(true);


Download ppt "Presentation: Advanced AXIS: Deployment Descriptors and Advanced Types."

Similar presentations


Ads by Google