3b.1 web services part ii implementation details itcs 4010 grid computing, 2005, unc-charlotte, b....
Post on 19-Dec-2015
215 views
TRANSCRIPT
![Page 1: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/1.jpg)
3b.1
Web Services
Part II
Implementation details
ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1.
![Page 2: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/2.jpg)
3b.2
What we know so far• Basis parts of a service-oriented architecture:
– The service provider, (server)– service requestor (client), – a service registry.
• If registry used, web services generally use a UDDI registry, which itself is a web service.
• SOAP used as the messaging protocol carrying XML documents and using an HTTP transport.
• WSDL, an XML language, is used to describe the web service.
![Page 3: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/3.jpg)
3b.3
• After registry populated with web service entries, client can access registry to find out whether desired web service exists in registry and if so where it is located.
• Registry responds with identification of server capable of satisfying needs of client.
• Then, client can access server for web service interface.
• Server responds with an WSDL document describing the service and how to access it.
• Client can then send web service a request requesting an operation.
• Result of operation returned in a message from the web service.
• All messages are SOAP messages.
![Page 4: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/4.jpg)
3b.4
Web Services
From http://www.globus.org
![Page 5: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/5.jpg)
3b.5
Web Service Container
• Web Services generally “hosted” in a web service container– software environment that provides
communication mechanisms to and from the web services and clients.
![Page 6: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/6.jpg)
3b.6
Several possible software environments designed for web services:
• Apache Axis (Apache eXtensible Interaction System)
• IBM Websphere
• Microsoft .NET
J2EE (Java 2 Enterprise Edition) server container also a candidate for hosting web services especially in enterprise (business) applications.
![Page 7: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/7.jpg)
3b.7
Apache Axis available for free down (Windows or Linux):
http://ws.apache.org/axis
Used for the first web service assignment in course.
Apache Axis requires an application server.– Can be installed on top of a servlet engine such as
Apache Jakarta Tomcat.– However, could be installed on top of a fully-
fleldged J2EE server.
![Page 8: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/8.jpg)
3b.8
Web service environment
Web service container
Web services Client
Will use an Application server (servlet engine)(e.g. Apache Jakara Tomcat)
(e.g. Apache Axis)
Network
SOAP messagescarried with HTTP transport
![Page 9: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/9.jpg)
3b.9
Client-Service Implementation
• In the implementation, it is convenient to use stubs - java classes suitable for web services defined with WSDL.
![Page 10: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/10.jpg)
3b.10
Client Stub
• Between client code and the network is a client stub, sometimes called client proxy.
• The client stub is responsible for taking a request from the client and converting the request into a SOAP request on the network - marshalling.
• Also responsible for receiving SOAP responses
on network and converting to a suitable form for client.
![Page 11: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/11.jpg)
3b.11
Server Stub
• Between the service and the network is a server stub, sometimes called a skeleton.
• Responsible for receiving a SOAP request from the client stub and converting it into a suitable form for the service -unmarshalling.
• Also converts the response from the service into a SOAP message for the client stub.
![Page 12: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/12.jpg)
3b.12
Web Service Application
![Page 13: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/13.jpg)
3b.13
Steps
• Client calls client stub.• SOAP request sent across network• Server stub receives request and sends
request to service• Service send result to serve stub• Server stub sends result across network to
client stub.• Client stub sends result to client.
![Page 14: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/14.jpg)
3b.14
Web Service Application
Call client stubSOAP
requestRequest service
Result returnedSOAP
responseClient receives result
![Page 15: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/15.jpg)
3b.15
Web Service Description
• Recall use an Interface Description language (IDL) called WSDL to formally describe a service, what is does, how it is accessed, etc.
![Page 16: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/16.jpg)
3b.16
Web Service Definition Language (WSDL)
A W3C standard XML document that describes three fundamental properties of a service:
• What it is - operations (methods) it provides.• How it is accessed - data format, protocols.• Where it is located - protocol specific network
address.
![Page 17: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/17.jpg)
3b.17
Math Web service
For concreteness, let us consider the web service used in assignment 1. A simple version is:
public class MyMath{
public int squared(int x){
return x * x;}
}
![Page 18: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/18.jpg)
3b.18
QuestionWhat does this service do?
Answer
![Page 19: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/19.jpg)
3b.19
Elements of a WSDL document
![Page 20: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/20.jpg)
3b.20
Parts of a WSDL Document• Root definitions - namespaces
• portType definitions - abstract definition of service
• Message definitions - parameters in method signature
• Type definitions - data types
• Binding definitions - to protocols i.e. SOAP over HTTP
• Service definitions - where service is, ports
![Page 21: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/21.jpg)
3b.21
WSDL file for math web service
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions targetNamespace="http://DefaultNamespace"xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://DefaultNamespace"xmlns:intf="http://DefaultNamespace"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="squaredRequest"><wsdl:part name="in0" type="xsd:int"/>
</wsdl:message><wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/></wsdl:message><wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0"><wsdl:input message="impl:squaredRequest" name="squaredRequest"/><wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation></wsdl:portType><wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/><wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/><wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input><wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output></wsdl:operation>
</wsdl:binding><wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding" name="MyMath"><wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/>
</wsdl:port></wsdl:service>
</wsdl:definitions>
![Page 22: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/22.jpg)
3b.22
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions targetNamespace="http://DefaultNamespace"xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://DefaultNamespace"xmlns:intf="http://DefaultNamespace"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="squaredRequest"><wsdl:part name="in0" type="xsd:int"/>
</wsdl:message><wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/></wsdl:message><wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0"><wsdl:input message="impl:squaredRequest" name="squaredRequest"/><wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation></wsdl:portType><wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/><wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/><wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input><wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output></wsdl:operation>
</wsdl:binding><wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding" name="MyMath"><wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/>
</wsdl:port></wsdl:service>
</wsdl:definitions>
Namespaces
Message definitions
portType
Bindings
Service definitions
![Page 23: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/23.jpg)
3b.23
Root Definitions Namespaces
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions targetNamespace="http://DefaultNamespace"xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://DefaultNamespace"xmlns:intf="http://DefaultNamespace"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
![Page 24: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/24.jpg)
3b.24
portType
Describes “What” - an abstract definition of service operation. Uses the elements:
• message definitions - a set of parameters referred to by method signature, decomposed into parts
• type definitions - defines all data types used
![Page 25: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/25.jpg)
3b.25
<wsdl:portType name="MyMath"><wsdl:operation name="squared" parameterOrder="in0"><wsdl:input message="impl:squaredRequest" name="squaredRequest"/><wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation></wsdl:portType>
portType Definitions
![Page 26: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/26.jpg)
3b.26
<wsdl:message name="squaredRequest"><wsdl:part name="in0" type="xsd:int"/>
</wsdl:message><wsdl:message name="squaredResponse"><wsdl:part name="squaredReturn" type="xsd:int"/>
</wsdl:message>
Message Definitions
Standard XML integer type –no special types in this example
![Page 27: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/27.jpg)
3b.27
Binding
Describes “how” the elements in abstract interface (portType) are converted in actual data representations and protocols e.g. SOAP over HTTP.
![Page 28: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/28.jpg)
3b.28
<wsdl:binding name="MyMathSoapBinding" type="impl:MyMath"><wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/><wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/><wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input><wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output></wsdl:operation>
</wsdl:binding>
Binding definitions
![Page 29: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/29.jpg)
3b.29
port and service
Describe “where” service is.
• port - describes how a binding is deployed at the endpoint of a network
• service - a named collection of ports
![Page 30: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/30.jpg)
3b.30
<wsdl:service name="MyMathService"><wsdl:port binding="impl:MyMathSoapBinding" name="MyMath">
<wsdlsoap:address location="http://localhost:8080/axis/testaccount/MyMath"/></wsdl:port>
</wsdl:service></wsdl:definitions>
Port/Service Definitions
Where math service is
![Page 31: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/31.jpg)
3b.31
Build and deploy a web service
Several ways to create a web service within a container and have accessible by clients.
Fundamental service components to build are:
• Web service code
• WDSL service description file
• Web service stub
and client components:
• Client stub
• Client code
![Page 32: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/32.jpg)
3b.32
What to create to deploy and test a service
Client
Client stub Server stub
Service
ContainerClient Applications
WSDLservice
description
Web service code
WDSL service description file
Web service stub
Client stub
Client code
![Page 33: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/33.jpg)
3b.33
In the following, we will assume that we are using Apache Axis, which has several tools for building and deploying a web service.
![Page 34: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/34.jpg)
3b.34
Java Web Service (JWS) deployment facility
Absolute simplest way in Axis to deplore a web service: • First, web service class file with methods created.• Then file simply renamed as .jws and dropped into a specific
directory that axis expects .jws services to be.
Service code with .jws extension interpreted as a web service. .jws file automatically compiled if necessary when service called. All public methods in the service code available and accessible as service operations.
• Simple and used in assignment 1 but has limitations.– Restrictions include using globally known data types, i.e., data types known
to Axis. If not part of standard type mappings, one must declare mappings.
![Page 35: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/35.jpg)
3b.35
jws facilityCould actually use web service after deployment with JWS without using a WSDL file nor stubs. One could just use service URL, which would have a .jws extension. Client and service need code to make SOAP calls.
However, one would normally create a WSDL file and the stubs, and get the stubs to handle the SOAP. That is done in assignment 1.
![Page 36: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/36.jpg)
3b.36
Web Service Deployment Descriptor (WSDD)
• WSDD is an XML language used to describe how to deploy a service.
• Provides for greater flexibility than with jws “instant” deployment facility.
![Page 37: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/37.jpg)
3b.37
WSDD file for MyService
<deployment xmlns="http://xml.apache.org/axis/wsdd/
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="... MyService"/>
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
![Page 38: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/38.jpg)
3b.38
Deployment with WSDD file
Once WSDD file deploy.wsdd created, can deploy with Axis tool AdminClient:
java org.apache.axis.client.AdminClient deploy.wsdd
This method not use in assignment 1.
![Page 39: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/39.jpg)
3b.39
Creating WSDL file
Several ways this can be approached:
• Create service code first and use as basis for WSDL file
or• Create WSDL file first and use this as basis
for the service code
Second method probably better from a Software Engineering perspective, but will look at both.
![Page 40: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/40.jpg)
3b.40
WSDL from Service CodeJava2WSDL Tool
Axis Java2WSDL program generates WSDL file (and its schema) from service code.
Program has number of flags including to specify:
• Name of the output WSDL file (-o flag)
• Location (URL) of the service (-l flag)
• Namespace of WSDL file (-n flag)
• Mapping from package to namespace (-p flag)
![Page 41: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/41.jpg)
3b.41
Example
Suppose we have interface MyMath.java for our service as:
public interface MyMath {
public int squared(int x)
}
To create WDSL file MyMath.wsdl from this interface file, we might issue command:
% java org.apache.axis.wsdl.Java2WSDL -o MyMath.wsdl
-l "http://localhost:8080/axis/services/MyMath" MyMath
![Page 42: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/42.jpg)
3b.42
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions targetNamespace="http://DefaultNamespace"xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://DefaultNamespace"xmlns:intf="http://DefaultNamespace"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><!--WSDL created by Apache Axis version: 1.2Built on May 03, 2005 (02:20:24 EDT)-->
<wsdl:message name="squaredRequest"><wsdl:part name="in0" type="xsd:int"/>
</wsdl:message><wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/></wsdl:message><wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0"><wsdl:input message="impl:squaredRequest" name="squaredRequest"/><wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation></wsdl:portType><wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/><wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/><wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/></wsdl:input><wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/></wsdl:output>
</wsdl:operation></wsdl:binding><wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding" name="MyMath"><wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/>
</wsdl:port></wsdl:service>
</wsdl:definitions>
WSDL file created
![Page 43: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/43.jpg)
3b.43
Stubs from WSDL
• If we have WSDL document for service, can use tools to generate client and server stubs:
– Axis WSDL2Java program generates stubs for use on client and server
– Example of this in assignment 1.
![Page 44: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/44.jpg)
3b.44
Axis tool WSDL2Java
Has a number of flags, including to specify:
• Root directory of output files (-o flag)
• Create server-side bindings for web service (-s flag)
• Deploy server stub (skeleton) or deploy implementation( -S true/false)
• Add scope to deploy.wsdd, "Application", Request" or "Session" (-d flag)
• Mapping all namespace in WSDL document to same Java package name (-p flag)
![Page 45: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/45.jpg)
3b.45
WSDL2Java Example
Suppose we have wsdl file MyMath.wsdl for our service. Invoke as:
java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s
-S true
-p localhost.axis.yourusername.MyMath_jws MyMath.wsdl
![Page 46: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/46.jpg)
3b.46
WSDL from Running ServiceIn Axis, can generate WSDL document directly from a running deployed service. Add ?wsdl onto service URL.
Example
If MyMath already deployed, say with the jws deployment facility, then setting browser to point to:
http://yourserver.yourdomain.edu:8080/axis/…/MyMath.jws?wsdl
will display the WSDL file. Port number (8080) may be different in an actual system.
![Page 47: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/47.jpg)
3b.47
Putting all together
Can couple ?wsdl method with invoking WSDL2Java to create required files with composite command:
java -classpath $AXISCLASSPATH org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/yourusername/MyMath.jws?wsdl
Will generate a directory structure .../… /MyMath.jws/ and four files within MyMath.jws:
• MyMath.java -- source for the Java interface for MyMath class.
• MyMathService.java - source for Java interface.
• MyMathServiceLocator.java - source for Java class MyMathServiceLocator.
• MyMathSoapBindingStub.java - source for Java class MyMathSoapBindingStub.
These files need to be compiled with, for example, the command:javac -classpath $AXISCLASSPATH
localhost/axis/yourusername/MyMath_jws/*.java
![Page 48: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/48.jpg)
3b.48
Client side programmingOnce deployed service, want to use it or allow others to use it. Depending upon details of deployed service and web service environment, a simple Java program can be used to access service such as:
import localhost.axis.yourusername.MyMath_jws.MyMathServiceLocator;import localhost.axis.yourusername.MyMath_jws.MyMathService;import localhost.axis.yourusername.MyMath_jws.MyMath;
public class MyMathClient {public static void main(String args[]) throws
Exception { MyMathService service = new MyMathServiceLocator(); MyMath myMath = service.getMyMath(); int x = (new Integer(args[0])).intValue(); System.out.println("The square of " + args[0] + " is "
+ myMath.squared(x)); }}
![Page 49: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/49.jpg)
3b.49
Quiz
What is Apache Axis?
(a) A tool used by American Indians
(b) A hosting environment for web services
(c) A compiler
(d) A type of make tool
![Page 50: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/50.jpg)
3b.50
Which of the following contains all the services that have been deployed?
(a) Class
(b) Shell
(c) Container
(d) Object
![Page 51: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/51.jpg)
3b.51
What is a client stub?
(a) A way of offending a customer
(b) Code between the client code and the network
(c) A document that explains the client code
(d) None of the other answers
![Page 52: 3b.1 Web Services Part II Implementation details ITCS 4010 Grid Computing, 2005, UNC-Charlotte, B. Wilkinson, slides 3b version 0.1](https://reader037.vdocuments.us/reader037/viewer/2022110322/56649d3b5503460f94a162be/html5/thumbnails/52.jpg)
3b.52
More information on Axis
http://xml.apache.org/axis