57
1 95-702 OCT Master of Information System Management QuickTime™ and a TIFF (Uncompressed) d are needed to see t Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

  • View
    218

  • Download
    2

Embed Size (px)

Citation preview

Page 1: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Organizational Communications and Distributed Object Technologies

Lecture 7: Axis2

Page 2: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Apache Axis2 (1)

• Since 2004 (a new Apache Axis).• A core engine for web services.• Compares with Microsoft Indigo.• Runs under any J2EE server.• Will include WS-Reliable Messaging

(Sandesha2) WS-Coordination, WS-AtomicTransaction, WS-BusinessActivity (Kandula2), WS-Security (Rampart),

WS-Addressing (out of the box).

Page 3: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Apache Axis2 (2)• Synchronous and Asynchronous web services.• MEP (Message Exchange Patterns).• Transport Independent core (SMTP, FTP, HTTP,

MOM, etc.).• WSDL 1.0 and 2.0.• WSDL2Java and Java2WSDL.• Supports queries for WSDL (using ?wsdl) schema (using ?xsd) and policies (using ?policy).• Service Archive wizard for Eclipse.• Code generation wizard for Eclipse.

Page 4: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Installation

• Main web site: http://ws.apache.org/axis2/• Use any J2EE web container.• Here, we will use Tomcat.

Page 5: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Web Container Directory

apache-tomcat-6.0.10

conf bin lib webapps common logs work

axis2

Page 6: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

axis2-web WEB-INF

classes conf lib modules services web.xml

• This directory structure is created by running the ant build script provided with Axis2. • The entire structure is compressed as a java archive and written to the file axis2.war. • The axis2.war file is copied into Tomcat’s webapp directory. • The file axis2.war is expanded under the directory named axis2. • Delete the axis2 directory before changing the war. In that way the war will be expanded again into a new axis2 directory.• Normally, you leave this directory structure in place. Add and update new web services within this existing directory structure.

axis2 axis2.war

webappsAxis2 Directory Structure (1)

This is arelativelyfixed areato workin.

Page 7: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

axis2-web WEB-INF

classes conf lib modules services web.xml

Axis2 administrationpages. Use admin to temporarily add services or engage oror disengage modules. The configuration description found in conf/axis2.xmlis not changed so these changes are temporary. Default username is admin.Default password is axis2.

Axis2 Directory Structure (2)axis2

webapps

Page 8: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

895-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

axis2-web WEB-INF

classes conf lib modules services web.xml

Classes needed byAxis2 itself.

Axis2 Directory Structure (3)

axis2

webapps

Page 9: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

995-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Directory Structure (4)

axis2-web WEB-INF

classes conf lib modules services web.xml

axis2.xml is an important file Defines how received messages are handled. Defines transport senders and receivers. Determines which modules are active. Defines order of phases and how handlers are to be executed within each phase.

axis2

webapps

Page 10: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1095-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Directory Structure (5)

axis2-web WEB-INF

classes conf lib modules services web.xml

.jar (Java archive)files supportingAxis2 activities

axis2

webapps

Page 11: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

axis2-web WEB-INF

classes conf lib modules services web.xml

.mar (module archive) filesare usedto extend axis2 - addinghandlers to the message stream.

Axis2 Directory Structure (6)axis2

webapps

Page 12: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Directory Structure (7)

axis2-web WEB-INF

classes conf lib modules services web.xml

Actual classes for the providing of business services..arr (axis archive) files reside here.

axis2

webapps

Page 13: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Directory Structure (8)

axis2-web WEB-INF

classes conf lib modules services web.xml

META-INF

services.xml

Package path to .class

Explodeddirectoryformat

MyCoolService

axis2

webapps

Page 14: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Directory Structure (9)

axis2-web WEB-INF

classes conf lib modules services web.xml

META-INF

services.xml

Package path to .class

MyCoolService

axis2

webapps

Defines the service name.Defines scope,e.g., “application”.Associates MEPs with receivers.Path to service classes.

Page 15: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

axis2-web WEB-INF

classes conf lib modules services web.xml

Apache Axis2 is a J2EE web application.The axis2 servlet is referred to in this file.

Axis2 Directory Structure (10)

axis2

webapps

Page 16: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Message Life Cycle

Page 17: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Axis2 Components

Page 18: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1895-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

SOAP Processing (1)Handlers runwithin phases.

Both pipes havedefault phases and have userphase extensibility.

Out pipe In pipe

Transport may be HTTPor JMS, etc.

Page 19: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

1995-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

SOAP Processing (2)

The handlers can be registered in global, service, or operation scopes and the final handler chain is calculated combining the handlers from all the scopes.Usually, the handlers operate on the SOAP headers. The receiver or sender may be on the client or the server.

Page 20: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2095-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Processing Model

UserApplication

Client API Handlers Transport

sender

Transportlistener

HandlersHandlersService

network

• Each phase is a collection of handlers.• We can control which handler goes into which phase and the order of execution within phases.• Handlers are defined in “modules”. E.g., Rampart is a WS-Security module. WS-Adressing is found within webapps/axis2/WEB-INF/modules/addressing-1.1.1.mar

Page 21: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Default Processing Model

UserApplication

Client API

Transportsender

Transportlistener

Dispatcherselects application

Service

network

- Dispatcher finds the service and operation described in the SOAP message.- Services are placed behind Tomcat in WEB-INF/services.- Modules are placed behind Tomcat in WEB-INF/modules

Message Receiver

Page 22: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Incoming Message Phases• Transport Phase - The handlers are in the phase meant to process transport

specific information such as validating incoming message by looking at various transport headers, add data into message context etc.

• Pre-Dispatch Phase- The main functionality of the handlers in this phase is to populate message context in order to do the dispatching. As an example, processing of addressing headers of the SOAP message, if any, happen in this phase. Addressing handlers extract information and put them in to the message context.

• Dispatch Phase - The Dispatchers run in this phase and tries to find the correct service and operation this particular message is destined to.

The post condition of the dispatch phase (any phase can contain a post condition) checks whether a service and an operation was found by the dispatchers. If not the execution will halt and throws out a "service not found error".

• User Defined Phases - Users are allowed to engage their custom handlers here.• Message Validation Phase - Once the user level execution has taken place this

phase validates whether SOAP Message Processing has taken place correctly.• Message Processing Phase - The Business logic of the SOAP message is

executed here. A Message Receiver is registered with each Operation. This Message receiver (associated to the particular operation) will be executed as the last Handler of this phase.

Page 23: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Outgoing Message Phases• Message Initialize Phase - First phase of the Out Pipe. Serves

as the placeholder for the custom handlers• User Phases - This executes handlers in user defined phases• Transports Phase - Execute any transport handlers taken from

the associated transport configuration. The last handler would be a transport sender which would send the SOAP message to the target endpoint.

Page 24: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Blocking and Non-Blocking Clients

• When the client sends a message, the

application may wait to receive a response before moving on.

• Or, it may simply send a message and move on (after, perhaps, specifying a callback action to be completed when the response is received.)

Page 25: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

R/W The XML Through Objects

• WSDL is used to generate client side stub code.

• The Eclipse code generation wizard permits two types of data binding:

ADB Axis2 Data Binding XMLBeans Data binding• JiBX is new, not part of axis2, but may also be used.

Page 26: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

R/W The XML Through Objects

ADB Axis2 Data Binding Generates a main stub with many inner classes. Not a full schema compiler. Easy and best for simple calls.XMLBeans data binding Generates many classes. A full schema compiler. Harder but more versatile.

XML data bindingis the processof mappingobjects toXML.Both JAXBand XMLBeansread XSDLand generateJava classes.JiBX and CastorXML are otherexamples.

Page 27: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Example From The Axis2 User Guide

• The WSDL document of a service.• Client code using ADB.• Client code using XMLBeans.

Page 28: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2895-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

WSDL<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://apache.org/axis2/Axis2UserGuide" xmlns:intf="http://apache.org/axis2/Axis2UserGuide" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://apache.org/axis2/Axis2UserGuide">

Page 29: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

2995-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://apache.org/axis2/Axis2UserGuide" xmlns="http://www.w3.org/2001/XMLSchema"> <!-- ELEMENTS --> <element name="DoInOnlyRequest"> <complexType> <sequence> <element name="messageString" type="xsd:string"/> </sequence> </complexType> </element>

Namespaces will be used.

WSDL makes use of XSDL.

XSDL standard type.

Page 30: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3095-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<element name="TwoWayOneParameterEchoRequest"> <complexType> <sequence> <element name="echoString" type="xsd:string"/> </sequence> </complexType> </element> <element name="TwoWayOneParameterEchoResponse"> <complexType> <sequence> <element name="echoString" type="xsd:string"/> </sequence> </complexType> </element>

Request and response elementsare defined.

Page 31: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<element name="NoParametersRequest"> <complexType/> </element> <element name="NoParametersResponse"> <complexType/> </element> <element name="MultipleParametersAddItemRequest"> <complexType> <sequence> <element name="itemId" type="xsd:int"/> <element name="itemName" type="xsd:string"/> <element name="price" type="xsd:float"/> <element name="description" type="xsd:string"/> </sequence> </complexType> </element>

A request withseveral parts.

Page 32: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<element name="MultipleParametersAddItemResponse"> <complexType> <sequence> <element name="itemId" type="xsd:int"/> <element name="successfulAdd" type="xsd:boolean"/> </sequence> </complexType> </element> </schema> </wsdl:types>

A response with two parts.

Page 33: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<!-- MESSAGES -->

<wsdl:message name="DoInOnlyRequestMessage"> <wsdl:part name="input" element="impl:DoInOnlyRequest"/> </wsdl:message>

<wsdl:message name= "TwoWayOneParameterEchoRequestMessage"> <wsdl:part name="input" element="impl:TwoWayOneParameterEchoRequest"/> </wsdl:message> <wsdl:message name= "TwoWayOneParameterEchoResponseMessage"> <wsdl:part name="output" element="impl:TwoWayOneParameterEchoResponse"/> </wsdl:message>

Messages are defined as for inputor output and are made up of elements previously defined.

Page 34: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<wsdl:message name="NoParametersRequestMessage"> <wsdl:part name="input" element="impl:NoParametersRequest"/> </wsdl:message> <wsdl:message name="NoParametersResponseMessage"> <wsdl:part name="output" element="impl:NoParametersResponse"/> </wsdl:message>

<wsdl:message name="MultipleParametersAddItemRequestMessage"> <wsdl:part name="input" element="impl:MultipleParametersAddItemRequest"/> </wsdl:message> <wsdl:message name="MultipleParametersAddItemResponseMessage"> <wsdl:part name="output" element="impl:MultipleParametersAddItemResponse"/> </wsdl:message>

Page 35: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<!-- Port type (interface) -->

<wsdl:portType name="Axis2UserGuidePortType">

<wsdl:operation name="DoInOnly" parameterOrder="input"> <wsdl:input name="DoInOnlyRequestMessage" message="impl:DoInOnlyRequestMessage"/> </wsdl:operation>

<wsdl:operation name= "TwoWayOneParameterEcho" parameterOrder="input"> <wsdl:input name="TwoWayOneParameterEchoRequestMessage" message="impl:TwoWayOneParameterEchoRequestMessage"/> <wsdl:output name="TwoWayOneParameterEchoResponseMessage" message="impl:TwoWayOneParameterEchoResponseMessage"/> </wsdl:operation>

An interface is a collection ofoperations with inputs and outputs.

Page 36: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<wsdl:operation name="NoParameters" parameterOrder="input"> <wsdl:input name="NoParametersRequestMessage" message="impl:NoParametersRequestMessage"/> <wsdl:output name="NoParametersResponseMessage" message="impl:NoParametersResponseMessage"/> </wsdl:operation>

<wsdl:operation name="MultipleParametersAddItem" parameterOrder="input"> <wsdl:input name="MultipleParametersAddItemRequestMessage" message="impl:MultipleParametersAddItemRequestMessage"/> <wsdl:output name="MultipleParametersAddItemResponseMessage" message="impl:MultipleParametersAddItemResponseMessage"/> </wsdl:operation>

</wsdl:portType>

Page 37: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<!-- BINDING (bind operations) --> <wsdl:binding name="Axis2UserGuideSoapBinding" type="impl:Axis2UserGuidePortType">

<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="DoInOnly"> <wsdlsoap:operation soapAction="DoInOnly"/> <wsdl:input> <wsdlsoap:body use="literal"/> </wsdl:input> </wsdl:operation>

Style may be rpcor document.Use may be literalor encoded.Document/Literalincludes no typeinformation withinthe SOAP (literal)and the content of

the SOAP body may be validated (document).

The SOAP messages may be constructed inseveral ways. Here we make our selections.

Page 38: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3895-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<wsdl:operation name="TwoWayOneParameterEcho"> <wsdlsoap:operation soapAction="TwoWayOneParameterEcho"/> <wsdl:input> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation>

<wsdl:operation name="NoParameters"> <wsdlsoap:operation soapAction="NoParameters"/> <wsdl:input> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation>

Page 39: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

3995-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<wsdl:operation name="MultipleParametersAddItem"> <wsdlsoap:operation soapAction="MultipleParametersAddItem"/> <wsdl:input> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding>

Page 40: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4095-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

<!-- SERVICE -->

<wsdl:service name="Axis2UserGuideService"> <wsdl:port binding="impl:Axis2UserGuideSoapBinding" name="Axis2UserGuide"> <wsdlsoap:address location= "http://localhost:8080/axis2/services/Axis2UserGuide"/> </wsdl:port> </wsdl:service></wsdl:definitions>

The service location.

Page 41: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Client Using ADBpackage org.apache.axis2.axis2userguide;

import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.DoInOnlyRequest;

import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoRequest;import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersRequest;import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemRequest;

import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoResponse;import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersResponse;import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemResponse;

The request and response messages appear as inner classesof the generated stub.

Page 42: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

public class Client{

public static void main(java.lang.String args[]){ try{ Axis2UserGuideServiceStub stub = new Axis2UserGuideServiceStub ("http://localhost:8080/axis2/services/Axis2UserGuideService");

doInOnly(stub); twoWayOneParameterEcho(stub); noParameters(stub); multipleParameters(stub);

} catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

Page 43: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* do in only */ public static void doInOnly(Axis2UserGuideServiceStub stub){ try{ DoInOnlyRequest req = new DoInOnlyRequest();

req.setMessageString("An in only request");

stub.DoInOnly(req); System.out.println("done");

} catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

This request class wasimported as an inner class of thestub.

Here we populate therequest.

DoInOnly is a methodof the stub class.

Page 44: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* two way call/receive */ public static void twoWayOneParameterEcho(Axis2UserGuideServiceStub stub){ try{ TwoWayOneParameterEchoRequest req = new TwoWayOneParameterEchoRequest();

req.setEchoString("echo! ... echo!");

TwoWayOneParameterEchoResponse res = stub.TwoWayOneParameterEcho(req);

System.out.println(res.getEchoString()); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

Note the pattern:Build a requestand pass it tothe appropriatemethod of the stubclass. A responsemessage may bereturned.

Page 45: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* No parameters */ public static void noParameters(Axis2UserGuideServiceStub stub){ try{ NoParametersRequest req = new NoParametersRequest();

System.out.println(stub.NoParameters(req));

} catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

Page 46: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* multiple parameters */ public static void multipleParameters(Axis2UserGuideServiceStub stub){ try{ MultipleParametersAddItemRequest req = new MultipleParametersAddItemRequest();

req.setPrice((float)1.99); req.setItemId((int)23872983); req.setDescription("Must have for cooking"); req.setItemName("flour");

MultipleParametersAddItemResponse res = stub.MultipleParametersAddItem(req);

System.out.println(res.getSuccessfulAdd()); System.out.println(res.getItemId()); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }}

Same pattern.Two valuesreturned.

Page 47: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Client Using XMLBeanspackage org.apache.axis2.axis2userguide;

public class Client{ public static void main(java.lang.String args[]){ try{ Axis2UserGuideServiceStub stub = new Axis2UserGuideServiceStub ("http://localhost:8080/axis2/services/Axis2UserGuideService");

doInOnly(stub); twoWayOneParameterEcho(stub); noParameters(stub); multipleParameters(stub);

} catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

The SOAP on the wireis the same. This is approach is more document oriented.

Page 48: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4895-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* fire and forget */ public static void doInOnly(Axis2UserGuideServiceStub stub){ try{ DoInOnlyRequestDocument req = DoInOnlyRequestDocument.Factory.newInstance();

DoInOnlyRequestDocument.DoInOnlyRequest data = req.addNewDoInOnlyRequest();

data.setMessageString("fire and forget it!");

stub.DoInOnly(req);

System.out.println("done"); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

The stub has a DoInOnly methodtaking a DoInOnlyRequestDocument.

The requestdocument isgot from afactory.

It’s populatedwith data.

Page 49: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

4995-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* two way call/receive */ public static void twoWayOneParameterEcho(Axis2UserGuideServiceStub stub){ try{ TwoWayOneParameterEchoRequestDocument req = TwoWayOneParameterEchoRequestDocument.Factory.newInstance(); TwoWayOneParameterEchoRequestDocument.TwoWayOneParameterEchoRequest data = req.addNewTwoWayOneParameterEchoRequest();

data.setEchoString("echo! ... echo!");

TwoWayOneParameterEchoResponseDocument res = stub.TwoWayOneParameterEcho(req);

System.out.println(res.getTwoWayOneParameterEchoResponse().getEchoString()); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

Same pattern butthe response document is gotfrom the call.

Page 50: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5095-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* No parameters */ public static void noParameters(Axis2UserGuideServiceStub stub){ try{ NoParametersRequestDocument req = NoParametersRequestDocument.Factory.newInstance(); NoParametersRequestDocument.NoParametersRequest data = req.addNewNoParametersRequest();

System.out.println(stub.NoParameters(req)); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }

Page 51: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5195-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* multiple parameters (1) */ public static void multipleParameters(Axis2UserGuideServiceStub stub){ try{ MultipleParametersAddItemRequestDocument req = MultipleParametersAddItemRequestDocument.Factory.newInstance(); MultipleParametersAddItemRequestDocument. MultipleParametersAddItemRequest data = req.addNewMultipleParametersAddItemRequest();

data.setPrice((float)1.99); data.setItemId((int)23872983); data.setDescription("Must have for cooking"); data.setItemName("flour");

Page 52: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5295-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

/* multiple parameters (2) */

MultipleParametersAddItemResponseDocument res = stub.MultipleParametersAddItem(req); MultipleParametersAddItemResponseDocument. MultipleParametersAddItemResponse dataRes = res.getMultipleParametersAddItemResponse();

System.out.println(dataRes.getSuccessfulAdd()); System.out.println(dataRes.getItemId()); } catch(Exception e){ e.printStackTrace(); System.out.println("\n\n\n"); } }}

Page 53: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5395-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Writing A Service

• Code First Approach Generate WSDL from existing code.• WSDL First Approach Generate skeleton code from existing WSDL.

Page 54: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5495-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Request Scope Service (1) package scope.experiment;

public class ScopeMan {

private static int y = 3; private int x = 9;

public int bumpInstanceVar() { return ++x; } public int bumpStaticVar() { return ++y; } }

Page 55: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5595-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Request Scope Service (2) package scope.experiment;

public class ScopeClient {

public static void main(String args[]) throws Exception {

TestScopeStub stub = new TestScopeStub(); TestScopeStub.BumpStaticVarResponse res = stub.bumpStaticVar(); int answer = res.get_return(); System.out.println(answer);

TestScopeStub.BumpInstanceVarResponse resi = stub.bumpInstanceVar(); int instance = resi.get_return(); System.out.println(instance); }}

The static variable changes oneach call butthe instance variable isalways reset.

Page 56: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5695-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Application Scope services.xml

<service name ="TestScope" scope="application"> <description>This is a scope testing project</description> <parameter name="ServiceClass">scope.experiment.ScopeMan</parameter> <operation name="bumpInstanceVar"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </operation> <operation name="bumpStaticVar"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </operation></service>

Page 57: 95-702 OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 7: Axis2

5795-702 OCT

Master of Information System Management

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

Application Scope (2) package scope.experiment;

public class ScopeClient {

public static void main(String args[]) throws Exception {

TestScopeStub stub = new TestScopeStub(); TestScopeStub.BumpStaticVarResponse res = stub.bumpStaticVar(); int answer = res.get_return(); System.out.println(answer);

TestScopeStub.BumpInstanceVarResponse resi = stub.bumpInstanceVar(); int instance = resi.get_return(); System.out.println(instance); }}

The static variable changes oneach call andso does theinstance variable.