Lektion 5 3D

concepcionsockΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 4 χρόνια και 11 μήνες)

257 εμφανίσεις

19
-

WebServices



2










NOEA

2009

Java
-
kursus


Web Services

Webservices in Java


Web Service client


Selected and edited slides from Siva Jagadeesan


The original version is here:
Intro to Web Services and
Apache Axis

3










NOEA

2009

Java
-
kursus


Web Services

Outline


Web Services Basics


What is Web Service?


Web Services Architecture


XML Messaging


XML
-
RPC


SOAP


What is WSDL?


Development plan for Service Requestor


Development plan for Service Provider


4










NOEA

2009

Java
-
kursus


Web Services

Outline


Intro to Apache Axis


What is Apache Axis?


Architecture of Apache Axis


Features of Apache Axis


Installing Apache Axis


Publishing Web Service through Apache Axis


Walkthrough of deploying and accessing a simple web
service using Apache Axis

5










NOEA

2009

Java
-
kursus


Web Services

What is Web Service?

A Web Service is any service that



is available over the web



uses standardized XML messaging



is OS and Programming language independent


6










NOEA

2009

Java
-
kursus


Web Services

XML Messaging

There are two ways of XML Messaging




XML
-
RPC



SOAP

7










NOEA

2009

Java
-
kursus


Web Services

What is XML
-
RPC ?


is a simple protocol that uses XML messages to perform
RPC


Request are encoded in XML and send via HTTP


Response are encoded in XML and received via HTTP


is a easiest way to get started with web services

8










NOEA

2009

Java
-
kursus


Web Services

Sample XML
-
RPC Request

<methodCall>


<methodName>



com.agram.sayHello


</methodName>


<params>



<param>




<value>Java</value>



</param>


</params>

</methodCall>

9










NOEA

2009

Java
-
kursus


Web Services

Sample XML
-
RPC Response

<methodResponse>


<params>



<param>




<value>





<string>Hello Java</string>




</value>



</param>


</params>

</ methodResponse >

10










NOEA

2009

Java
-
kursus


Web Services

What is SOAP?


S
imple
O
bject
A
ccess
P
rotocol


SOAP is slightly more complicated than the XML
-
RPC


SOAP extended XML
-
RPC


It uses XML namespaces and XML Schemas.

11










NOEA

2009

Java
-
kursus


Web Services

SOAP Message


Envelope

is like a wrapper for content


Header

is a optional element that
could contain control information


Body

element includes requests and
responses


Body element will include a
Fault

element in the event of an error

SOAP Message

Envelope

Header

Body

12










NOEA

2009

Java
-
kursus


Web Services

Sample SOAP Request

<SOAP
-
ENV:Envelope


xmlns:xsd="http://www.w3.org/2001/XMLSchema"



xmlns:SOAP
-
ENV=http://schemas.xmlsoap.org/soap/envelope/




xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance">




<SOAP
-
ENV:Body>





<ns1:
sayHello




xmlns:ns1="http://agram.com/">






<name xsi:type="xsd:string">Java</name>



</ns1:
sayHello
>




</SOAP
-
ENV:Body>



</SOAP
-
ENV:Envelope>


13










NOEA

2009

Java
-
kursus


Web Services

Sample SOAP Response

<SOAP
-
ENV:Envelope


xmlns:xsd="http://www.w3.org/2001/XMLSchema"



xmlns:SOAP
-
ENV=http://schemas.xmlsoap.org/soap/envelope/




xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance">




<SOAP
-
ENV:Body>





<ns1:
sayHelloReponse





xmlns:ns1="http://agram.com/">




<result xsi:type="xsd:string">Hello Java</result>

</ns1:
sayHelloResponse
>





</SOAP
-
ENV:Body>



</SOAP
-
ENV:Envelope>


14










NOEA

2009

Java
-
kursus


Web Services

What is WSDL?


W
eb
S
ervices
D
escription
L
anguage


Has 6 major elements

1.
definitions



defines the name of the web service

2.
types



describes all the data types that will be transmitted

3.
message



defines the name of the message that will be transmitted

4.
portType



defines the operations

5.
binding



defines how the message will be transmitted

6.
service



defines where the service is located

15










NOEA

2009

Java
-
kursus


Web Services

Development plan for Service Requestor

1) Find the web service (Google, Xmethods.net etc.)

2) Retrieve service description file

3) Create XML
-
RPC or SOAP client

4) Invoke remote service

16










NOEA

2009

Java
-
kursus


Web Services

Development plan for Service Provider

5) Register new service via UDDI

1) Create the core functionality

2) Create XML
-
RPC or SOAP service wrapper

3) Create service description file

4) Deploy service

17










NOEA

2009

Java
-
kursus


Web Services

Make a WebService with NetBeans


First install NetBeans EE bundle 5.0 or later

Can be downloaded from
www.netbeans.org





To make a WebService in NetBeans is nearly as easy as in
VisualStudio....


18










NOEA

2009

Java
-
kursus


Web Services

Live Demo


Da NetBeans laver om for hver ny version er det bedre med
en tutorial fra dem, end screendumps på slides.


Tutorial for 6+ er her:

http://netbeans.org/kb/60/websvc/jax
-
ws.html


19










NOEA

2009

Java
-
kursus


Web Services

Exercise

1.
Make a web service client in Java.

Use an appropriate Web Service, ie. a weather service

F.eks iistest.noea.dk/weather

2.
Make a simple webservice in Java.

Use NetBeans, Eclipse or Axis