Embed
Email

Web Service Tutorail - The University of Texas at Dallas Home Page

Document Sample
Web Service Tutorail - The University of Texas at Dallas Home Page
Web Service Tutorial



Yunqi Ye

What is Web Service

• Definition from W3C

"Web Service is a software application identified

by a URI, whose interfaces and bindings are

capable of being defined, described, and

discovered by XML artifacts and which supports

direct interactions with other software

applications using XML-based messages via

internet-based protocols".

What is Web Service

• Every component that

– works in a network,

– is modular,

– is self-descriptive,

– provides services independent of platform and

application,

– conforms to an open set of standards and

– follows a common structure for description

and invocation.

Standards

• SOAP (Simple Object Access Protocol)

– XML messaging protocol for basic service

interoperability

• WSDL (Web Service Description

Language)

– Common grammar for describing services

• UDDI (Universal Description Discovery

and Integration)

– infrastructure required to publish and discover

services

Web Services Architecture

SOAP

• Simple Object Access Protocol

– Protocol for structured information exchange

– Processing

• The requestor wraps the invoking information

into a message and sends it to the service

• The service parses the message and runs the

method. Then it wraps the result into a response

message and sends it to the requestor

• The requestor parses the response message and

gets the result

– Specification: http://www.w3.org/TR/soap

SOAP Example

WSDL

• Web Service Description Language

– IDL for web service

– Contents

• Define data types

• Define SOAP messages (both request and response)

• Define the interaction (port, bindings)

• The definition of the service itself

– Required for support automated client side code

generation

– Specification: http://www.w3.org/TR/wsdl

WSDL Example

UDDI

• Universal Description Discovery and

Integration

– A platform-independent, XML-based registry,

enabling businesses to publish services

listings and discover each other and define

how the services and software applications

interact over the Internet

– Specification:

http://www.uddi.org/pubs/uddi_v3.htm

Java Web Service

• Tools

– NetBeans IDE + GlassFish

– http://java.sun.com/javaee/downloads/index.jsp

– The PCs in open lab have already installed them

– Advantage

– IDE can generate WSDL automatically

– IDE can generate client side code automatically for process

on SOAP messages

– Focus on the business logic

Create a Demo Web Service

• Step 1: Create a web application project

– 1. Select web application in project wizard

Create a Demo Web Service

• Step 1: Create a web application project

– 2. Input project name and location

Create a Demo Web Service

• Step 1: Create a web application project

– 3. Select server to deploy the web service

Create a Demo Web Service

• Step 1: Create a web application project

– 4. Finish the wizard

Create a Demo Web Service

• Step 2: Create web service

– 1. Add a web service to the project

Create a Demo Web Service

• Step 2: Create web service

– 2. Input service name, package

Create a Demo Web Service

• Step 2: Create web service

– 3. Finish the wizard and open the design view

Create a Demo Web Service

• Step 3: Add operations to the web service

– 1. Click Add Operation and input its properties

Create a Demo Web Service

• Step 3: Add operations to the web service

– 2. The operation in design view

Create a Demo Web Service

• Step 3: Add operations to the web service

– 3. Edit the operation in source view

Create a Demo Web Service

• Step 4: Deploy the web service

Create a Demo Web Service

• Step 5: Test the web service

Create a Demo Web Service Client

• Step 1: Create a java application project

– 1. Select java application in project wizard

Create a Demo Web Service Client

• Step 1: Create a java application project

– 2. Input project name and location

Create a Demo Web Service Client

• Step 1: Create a java application project

– 3. Finish the wizard

Create a Demo Web Service Client

• Step 2: Add web service client

– 1. Add web service client

Create a Demo Web Service Client

• Step 2: Add web service client

– 2. Provide WSDL URL

Create a Demo Web Service Client

• Step 2: Add web service client

– 3. Finish the wizard

Create a Demo Web Service Client

• Step 3: Add auto-generated source code

– 1. Open properties dialog

Create a Demo Web Service Client

• Step 3: Add auto-generated source code

– 2. Add the generated source code folder

Create a Demo Web Service Client

• Step 3: Add auto-generated source code

– 2. Add the generated source code folder (I)

Create a Demo Web Service Client

• Step 3: Add auto-generated source code

– 3. Add the generated source code folder (II)

Create a Demo Web Service Client

• Step 3: Add auto-generated source code

– 4. Add the generated source code folder (III)

Create a Demo Web Service Client

• Step 4: Access web service

– 1. Edit client main class

Create a Demo Web Service Client

• Step 4: Access web service

– 2. Build and Run

Deploy To Remote Server

• NetBeans has default local web server,

but we may need deploy the web service

to a remote server

• Step 1: Add a remote server

– Open menu Tools->Servers

– In the Servers dialog, click ‘Add Server’ button

to start Add Server wizard

Deploy To Remote Server

• Step 1: Add a remote server

– Wizard 1: Select ‘GlassFish V2’ server type

Deploy To Remote Server

• Step 1: Add a remote server

– Wizard 2: Select ‘Register Remote Domain’

Deploy To Remote Server

• Step 1: Add a remote server

– Wizard 3: Input IP or DNS of remote server

Deploy To Remote Server

• Step 1: Add a remote server

– Wizard 4: Input admin account and password

Deploy To Remote Server

Step 1: Add a remote server

– Review the new added server

Deploy To Remote Server

• Step 2: Update running server for demo

project

– Open project properties and select Run in

Catogories and change the Server

Deploy To Remote Server

• Step 3: Re-deploy the web service and

test it

• Step 4: Reconfigure the WSDL URL for

web service reference in demoClient

project

• Step 5: Re-build the client and run it

Configuration for Remote Server

• When add a remote server to NetBeans

IDE, use following information

– Host: aosj2ee01 ~ aosj2ee10.utdallas.edu

– Port: 5050 (Not the default 4848)

• This port is only for admin purpose. The web

server http port you used in your web service

WSDL URL is still 8080

– Admin username: aosadmin

– Admin password: aosadmin

Delete Web Service From The

Linux Server

• How to delete your web service from the

linux server

– Login the aosj2eexx server with your NetID

and password by ssh

– Run command

• $ /opt/glassfish/bin/asadmin undeploy --port 5050 -

-user aosadmin your_web_service_project_name

• Input password aosadmin when required

VERY IMPORTANT

• Every time you finish your development on

the project, DELETE your deployed web

service from the server. ONLY let your

web service run when you use it.

C/C++ Web Service

• Tools Preparation

– Axis2/C, gcc

– http://apache.norhex.com/ws/axis2/c/1_5_0/axis2c-

bin-1.5.0-linux.tar.gz

– Install Axis2/C

• Extract the binary tar package to a directory.

• Set AXIS2C_HOME environment variable pointing to the

location where you have extracted Axis2/C.

– $ export AXIS2C_HOME='/your_path_to_axis2c‘

– $ export

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AXIS2C_HOME

}/lib

C/C++ Web Service

– Run Axis2/C

– $ cd ${AXIS2C_HOME}/bin

• $ ./axis2_http_server

• The default port is 9090.

• You can use your own port by

• $ ./axis2_http_server -p your_own_port

Quick Start Guide

• Create a web service has the same operation as the

previous java web service

• Client send name

• Server respond Welcome

name!

• Create a web service client to access the web service

• More examples

• See :${AXIS2C_HOME}/samples

Create Web Service

• Step 1: Implement the functions defined by the

axis2_svc_skeleton interface.

– axis2_svc_skeleton interface expects the functions

init, invoke, on_fault and free to be implemented by

our service

• Step 2: Implement the create function, that

would create an instance of the service skeleton.

– The create function would create an

axis2_svc_skeleton and assign the respective

function pointers to map the axis2_svc_skeleton

interface to the interface implementation methods

Create Web Service

• Step 3: Implement axis2_get_instance and

axis2_remove_instance functions.

– These functions are used to create and destroy

service instances by the engine, and each service

must define these functions.

• Step 4: Implement the functions corresponding

to the operations of the service.

– For example, our sample welcome operation. It

accept an argument and return a welcome string to

the client

Create Web Service

• Sample File

Create Web Service

• Step 5: Write the services.xml file for the

service



hello



Quick start guide hello service sample.







Create Web Service

• Step 6: Complile the web service file

– $ gcc -shared -olibhello.so -

I$AXIS2C_HOME/include/axis2-1.5.0/ -

L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -

laxis2_parser -laxis2_engine -lpthread -

laxis2_http_sender -laxis2_http_receiver hello_svc.c

• Step 7: Deploy the web service

– $ cd $AXIS2C_HOME/services

– $ mkdir hello

– Copy the generated libhello.so and services.xml to

foler $AXIS2C_HOME/services/hello

– Restart the axis2_http_server

Create Web Service

• Step 8: Check the deployment

– Open http://ip_or_dns:9090/axis2/services

– If deploy successfully

• The hello web service will be shown

Create Web Service Client

•Step 1: Create a service client instance and set

options

•Step 2: Send the request and receive the

response

•Step 3: Process the response

•Sampe File

Create Web Service Client

• Step 4: Build the client

– $ gcc -o hello -

I$AXIS2C_HOME/include/axis2-1.5.0/ -

L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -

laxis2_parser -laxis2_engine -lpthread -

laxis2_http_sender -laxis2_http_receiver

hello_client.c -ldl -Wl,--rpath -

Wl,$AXIS2C_HOME/lib

Create Web Service Client

• Step 4: Run Client

– $ ./hello John

Welcome John!


Related docs
Other docs by rogerholland
Shilpa Bhoj
Views: 2211  |  Downloads: 0
Software Quality Assurance
Views: 1198  |  Downloads: 50
Chapter 2 - The metaphysical impulse
Views: 14  |  Downloads: 0
Sarah Moore 4750 Pear Ridge Dr
Views: 20  |  Downloads: 0
PROJECT 1
Views: 3  |  Downloads: 0
Property Custody Reciept
Views: 23  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!