645-jaxrpc-axis1

  • Uploaded by: Uday Kumar
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 645-jaxrpc-axis1 as PDF for free.

More details

  • Words: 684
  • Pages: 3
JAX-RPC Model

Introduction to JAXRPC

Service

JAXRPC Client

Tie Ye Wu http://www.ise.gmu.edu/~wuye

Dynamic Stub Proxy DLL

Endpoint

SOAP

SOAP

SWE 645 Component-based Software Development

HTTP

HTTP

TCP/IP

TCP/IP

sources: Java Web Service Architecture, James McGoven and etc., Morgan Kaufmann, Ch 4, 10, 11 (8 and 9 are supporting chapters)

INTERNET 2007-4-17

Axis SOAP Engine (SOAP 1.1 compliant, partial SOAP 1.2) a simple stand-alone server, a server which plugs into servlet engines such as Tomcat, extensive support for the Web Service Description Language (WSDL), • emitter tooling that generates Java classes from WSDL. • some sample programs, and • a tool for monitoring TCP/IP packets.

© Dr. Ye Wu

• RMI – Java Serialization • CORBA – IIOP • DCOM – ORPC • Web service – How to perform marshalling and unmarshalling?

3

Java.lang.String Java.util.Date Java.util.Calendar Java.math.BigInteger Java.math.BigDecimal

4

5

byte[]

Boolean

xsd:int

Int

xsd:byte

Byte

xsd:integer

java.math.BigInteg er

xsd:long

long

xsd:QName

javax.xml.namespa ce.QName

xsd:short

short

xsd:string

java.lang.String

xsd:decimal

• An object that is an instance of a class that conforms to JavaBean specification. (Not remote objects • An array • A java.lang.Exception class

xsd:hexBina ry

xsd:boolean

xsd:dateTime

© Dr. Ye Wu

© Dr. Ye Wu

xsd:base64Bin byte[] ary

• All Java primitives, with exception of a char. • An object that is an instance of

2007-4-17

2007-4-17

XML <-> Java Data Mapping in AXIS

Java-to-XML Marshalling

– – – – –

2

Data Type and Serialization

• • • •

2007-4-17

© Dr. Ye Wu

java.util.Cale ndar java.math.Bi gDecimal

xsd:double

Double

xsd:float

Float

2007-4-17

© Dr. Ye Wu

6

1

SOAP Binding and Encoding

Develop SOAP Service with Axis

• Encoded message

• • • •

– Axis - RPC style service

• Literal message – Axis - Document style service – Axis - Wrapped style service – Axis - Message service

2007-4-17

© Dr. Ye Wu

7

Developing the Axis service Prepare the deployment descriptor (WSDD) Deploy web service Develop Client program

2007-4-17

Developing the Axis service

<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="HelloWorld" provider="java:RPC"> <parameter name="className" value = "HelloWorldService"/> <parameter name="allowedMethods" value="*"/>

public class HelloWorldService { public HelloWorldService() {} public String HelloWorld() { return "Hello World!"; } } © Dr. Ye Wu

9

2007-4-17

Deploy Web Service

10

String endpointURL="http://hermes:9090/axis/services/HelloWorld"; String methodName = "HelloWorld";

Java org.apache.axis.client.AdminClient –p 9090 ?.wsdd

• Verify the deployment at http://hermes.gmu.edu:9090/axis

© Dr. Ye Wu

© Dr. Ye Wu

Develop Web Service Client

• Copy java class file into $AXIS_HOME/WEBINF/classes directory • Publishing service

2007-4-17

8

Prepare Deployment Descriptor

import java.util.*;

2007-4-17

© Dr. Ye Wu

11

Service service = new Service(); Call call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpointURL)); call.setOperationName(methodName); call.addParameter( "name", XMLType.XSD_STRING, ParameterMode.IN ); call.setReturnType(XMLType.XSD_STRING); res = (String)call.invoke(new Object[]{"aa"}); System.out.println(res); 2007-4-17

© Dr. Ye Wu

12

2

Advanced SOAP Programming

BeanSerializer • Develop your JavaBean • User JavaBean as a parameter or return value

• Passing Custom Type Input Parameters – BeanMapping – TypeMapping

public String HelloWorld(Myclass myClass) { return "Hello World!" + myClass.getPname() + " " + myClass.getClassname(); }

• Adding Handlers • Scoped Service – <service name="MyService"...> <parameter name="scope" value="value"/> ...

• Remote Administration (server-config.wsdd) <parameter name="enableRemoteAdmin" value="true"/>

2007-4-17

© Dr. Ye Wu

13

public Myclass(){}; void setClassname(String classname) { this.classname = classname;} void setPname(String pname) { this.pname = pname;} String getClassname() { return classname;} String getPname() { return pname; } } 2007-4-17

Prepare Deployment Descriptor

© Dr. Ye Wu

QName qn = new QName("urn:BeanS","Myclass"); call.registerTypeMapping(Myclass.class, qn, new org.apache.axis.encoding.ser.BeanSerializerFactory(Myclass.class, qn), new org.apache.axis.encoding.ser.BeanDeserializerFactory(Myclass.class, qn));

call.addParameter( "name", qn, ParameterMode.IN ); call.setReturnType(XMLType.XSD_STRING); Myclass myClass = new Myclass(); myClass.setClassname("aaa"); myClass.setPname("bbb"); String res = (String)call.invoke(new Object[]{myClass});

15

2007-4-17

Potential Issues with SOAP

© Dr. Ye Wu

© Dr. Ye Wu

16

Environment Setting export AXIS_HOME=/opt/tomcat-swe645/webapps/axis export CLASSPATH=$AXIS_HOME/lib/axis.jar:$CLASSPATH export CLASSPATH=$AXIS_HOME/lib/jaxrpc.jar:$CLASSPATH export CLASSPATH=$AXIS_HOME/lib/saaj.jar:$CLASSPATH export CLASSPATH=$AXIS_HOME/lib/commonslogging.jar:$CLASSPATH export CLASSPATH=$AXIS_HOME/lib/commonsdiscovery.jar:$CLASSPATH export CLASSPATH=$AXIS_HOME/lib/wsdl4j.jar:$CLASSPATH

• Lack of interoperability between SOAP implementations • Security mechanisms are immature • No guaranteed message delivery • No publish and subscribe • Performance

2007-4-17

14

Develop Web Service Client

<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="wuyeBeanS" style="java:RPC"> <parameter name="className" value = "BeanSHello"/> <parameter name="allowedMethods" value="*"/>

2007-4-17

© Dr. Ye Wu

17

2007-4-17

© Dr. Ye Wu

18

3

More Documents from "Uday Kumar"

Web Services Slides
November 2019 13
Wsdlcontracts
November 2019 13
Jax-ws
November 2019 13
Wsdl11soap12
November 2019 17
Hibernate Join Fetch
October 2019 19