Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab Practice 5 Meilan JIANG

Similar presentations


Presentation on theme: "Lab Practice 5 Meilan JIANG"— Presentation transcript:

1 Lab Practice 5 Meilan JIANG (meelankang@gmail.com)
Cyber infrastructure Research Laboratory Department of Advanced Technology Fusion Konkuk University

2 What is WSDL? WSDL is Web Services Description Language.
WSDL define detailed information about web service. The use of XML is a reasonable between a machine-readable and a human-readable document. WSDL document is complex and includes elements such as imports, types, schemes, messages, ports, bindings, and services. WSDL is Web Services Description Language. Wsdl define detailed information about web service. Used xml Which allows an application to understand how to invoke the service and what parameters are required. An actual WSDL document is complex and includes elements such as Imports, types, schemas, messages, ports, bindings, and services. I will explain about Theses element at next

3 WSDL Overview WSDL document is to state that it answers four questions about a web service. What do you do? What language do you speak? How do I talk to you? Where do I find you? This figure shows a high-level picture of the WSDL specification: <definitions/> <types/> What Data Types? <message/> <portType/> What Do you Do? <binding/> How? What do you do? This question is answered both in machine-readable and human-readable forms. The human-readable answers can be found in the <name/> and <documentation/> elements. The answer in machine-readable terms comes from the <message/> and the <portType/> Elements. What language do you speak?dipict What data types do you use? This question is answered using the <types/> elements. How do I talk to you? How does a client talk to the service? HTTP? SMTP? This question is answered using the <binding/> element. Where do I find you? Where can I find this web service? What is its URL? The answer in in the <service/> elements. Interface Definition <service /> Where? Interface Implementation WSDL Document

4 WSDL Document(1/4) <defnitions /> <types />

5 WSDL Document(2/4) <message /> <portType />

6 WSDL Document(3/4) < binding />

7 WSDL Document(4/4) <service />

8 A WSDL Document for StockQuote
We will use the tools provided by Axis to generate the WSDL document from our Java class as shown below: StockQuote.class services/Stockquote?wsdl Java Java2WSDL StockQuote Axis Servlet Java2WSDL We will use the tools provided by Axis to generate the WSDL document from our Java class as shown below: There are two ways to generate a WSDL document from an Existing web servcie This way is generate WSDL using the Axis servlet This way is generate wsdl with Java2WSDL StockQuote.wsdl

9 Try it out –Using the Axis servlet(1/2)
The easiest way to generate a WSDL document for a web service deployed with Axis is to navigate to When the Axis servlet detects the ?wsdl, it generates the WSDL based on the class file of the service.

10 Try it out –Using the Axis servlet(2/2)
This built-in support in the web interface will be very useful To publish a URL for the description Of a Web service in a registry like UDDI.

11 Try it out – with Java2WSDL(1/2)
Using the Java2WSDL tool > java org.apache.axis.wsdl.Java2WSDL com.wrox.jws.stockquote.StockQuote -l Before, we have to add the following files, The Xerces(XML parser) files: xml-apis.jar xercesImpl.jar The JAR files distributed with Axis axis.jar commons-logging.jar jaxrpc.jar wsdl4j.jar The .class file(not the .java file) of the StockQuote example

12 Try it out – with Java2WSDL(2/2)
Here is the Java2WSDL command for creating the StockQuote.wsdl file Regardless of the methodology that we use to generate the WSDL document, the result will be the same.

13 The <definitions /> Element
The root of every WSDL document is the <definitions /> element. targetNamespace = “ Describe our web service URL xmlns:impl=" xmlns:intf=" These namespaces define the implementation and definition namespaces for StockQuote Conceptually, a web service can be separated in to two WSDL files: Document for the definition of the interface of the web service(<types />, <message />,<portType />,<bindings />). Document for the implementation of the web service(<service />). xmlns:soapenc=" Describe SOAP encoing URL xmlns:wsdlsoap=" xmlns:xsd=" Desribe SOAP element and XML Schema Now I explain the different element in this WSDL document section by section. When we look at th <types/>element, we will see that it allows the XML Schema contained in a WS이 document to refer to itself

14 The <message /> Element
<message />element gives information about the data that travels from one endpoint to another. The getQuote() methods is described in terms of a request and a response. Message compared to Java methods and port type compared to Java classes. <message />element gives information about the data that travels from one endpoint to another. More specifically, the <message/> element depicts a one-way message. To describe an RPC method call, one needs an input message and an output message. Messages are grouped into operations that can be compared to Java methods, And these operations are grouped into Port types that can be compared to Java classes

15 The <portType /> Element
Describes and defines the operations(or methods) supported by the web service. WSDL supports four modes of operations: One-way Request-Response Solicit-Response Notification

16 The <portType /> Element
One-way (1) messge Client Webservice A message is sent to an endpoint of the service For instance, a client sends a message to a web service via SMTP or calls a method with a void return type over HTTP. In this case, only an input message appears in the operation:

17 The <portType /> Element
Request-Response (1) request Client Webservice (2) response This mode of operation is the most common. In this case, an input, an output, and an optional fault element appear in the operation. A non-void method call like getQuote() is An example of a request-reponse operation:

18 The <portType /> Element
Solicit-Reponse (1) Correlated message Client Webservice (2) mesage In this transmission mode, the endpiont is the client of another endpion. The format of the operation is similar to the request-respones mode, But the output is listed before the input. A possible use of this mode is an advertisement To which different client can send Different responses:

19 The <portType /> Element
Notification Client Webservice (1) message This mode is another version of the on-way transmission primitive where the endpoint sends The message rather than receives it. In this case, the operation only contains an output message. This is similar to event notification in GUI development.

20 The <binding /> Element
The <binding /> element describes how the operations defined in a port type are transitted over the network. 포트 타입 에 정의된 오퍼레이션이 어떻게 네트워크상으로 전송되는지를 기술한다. Name attribute specifies a unique identifier for this binding. The <wsdlsoap:binding>element indicates that the binding describes how the stockquote port type will be accessed via SOAP Style attribute indicate that SOAP message will follow the RPC formet Transport attribute indicates the SOAP transport that will be used. We use HTTP. We can use another value such as SMTP, <input> element defines the format of the SOAP body. Use attribute’s another value is literal. Use=“literal” in this case, the argument is an XML document fragment. <output > packet is identical to the input,

21 The <service /> Element
Specifies where to find the web service. The <service /> element is a collection of <port /> elements. We need to specify protocol-specific data for the actual location of the web service. We use the SOAP extensions for WSDL to specify the location of the service

22 The <import/ > Element
<service /> element allows clients to bind to one well-difined interface and switch implementation aw sill. To satisfy that requirement, the Java2WSDL Axis tool that we used earlier can be invoked to create two files: one for the interface definition and one for the interface implementation as shown in the nextpage’s diagram:

23 The import Element

24 Try It Out – WSDL Interface Definition Document
The following command creates two files, StockQuoete_interface,wsdl and StockQuoteImpl.wsdl > java org.apache.axis.wsdl.Java2WSDL com.wrox.jws.stockquote.StockQuote –l -O StockQuoteImpl.wsdl - L StockQuote_interface.wsdl java org.apache.axis.wsdl.Java2WSDL com.wrox.jws.stockquote.StockQuote –l -O StockQuoteImpl.wsdl – L StockQuote_interface.wsdl

25 Try It Out – WSDL Interface Definition Document
The StockQuote_Interface.wsdl document is the Stockquote.wsdl document reviewed earlier. The StockQuoteImpl is following WSDL Document. <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace=" xmlns:apachesoap=" xmlns:impl=" xmlns:intf=" xmlns:soapenc=" xmlns:wsdl=" xmlns:wsdlsoap=" xmlns:xsd=" <wsdl:import location="StockQuote_interface.wsdl" namespace=" <wsdl:service name="StockQuoteService"> <wsdl:port binding="intf:StockQuoteSoapBinding" name="StockQuote"> <wsdlsoap:address location=" </wsdl:port> </wsdl:service> </wsdl:definitions> The import element allows us to include one WSDL document into another.

26 The <types /> Element
What data types do you use? This question is answered using the <types/> elements. StockQuote.wsdl Type element contains the XML Schema for the these classes. Defined as an array of doubles encoded According to the SOAP encoding rules: Sequence element contains the elements generated From the MarketData instance data, That is the ticker symbol, the double values And the array of doubles for the market indice. Nillable=“true” attribute allows these string to be omitted. Market.wsdl

27 WSDL-Based Clients Using the WSDL documents we have generated, we will be able to automatically create client classes that provide an interface to the web service. StockQuote (Real Class) Web Service Client Java Call Java Call In this section, we will create a Java stub class and the Java cleasses Necessary to support it. The following diagram shows the relationship between the cilent and the server when using a stub When calling the getquote() method, Our application calls the stub class Stub class takes care of serializing (from java to XML) our input and sending them over the network via s SOAP call When the call completes, The stub class also takes care of deserializing(from xml to java) the return value. Network Axis Servlet StockQuote (stub) SOAP Call SOAP Call

28 Try It Out – StockQuoteClient
Generate the stub and its supporting classes. Using WSDL2Java class Axis provides this class Java org.apache.axis.wsdl.WSDL2Java StockQuote.wsdl WSDL2Java build the stub files make the classes

29 Try It Out – StockQuoteClient
Build the client. The client code is contained in the StockQuoteClinet class:

30 Try It Out – StockQuoteClient
StockQuote.java (interface) Corresponds to the stockquote portType in the WSDL file. Service Definition Interface(SDI) StockQuoteSoapBindingStub.java Stub class, It implements the SDI(StockQuote). StockQuoteService.java (interface) Derived from the <service />element in WSDL. StockQuoteServiceLocator.java Implements the StockQuoteService interfce. WSDL Element Java Class or Interfce For each element in A Java class <type /> <portType /> A Java interface <binding /> A stub class <service /> A service interface A service implementation(the locator) <fault />

31 Try It Out – StockQuoteClient
StockQuoteClient.java We get a reference to the StockQuoteService interface by creating an instance of the StockQuoteserviceLocator class: We get a reference to the StockQuote interface: We call the getQuote method as we would call any other local interface: 1 2 1 3 2 java com.wrox.jws.stoctquote.StockQuoteClient IBM 3

32 Summary WSDL is an important topic for two reasons.
First, we want people to be able to read descriptions of the services that we provide. Second, we want tools like WSDL2Java to automatically read a description and their users with a quick interface Four questions about web services What? Which? How? Where? In this chapter, we have coverd the important topic of web service description It is an important topic for two reasons. First, we want people to be able to read descriptions of the services that we provide. Second, we want tools like WSDL2Jazva to automatically read adescription of our web serves And their users with a quick interface to our web services. What? The machine-readable answer to that question is in the <message/> and <portType />element. The human-readable answer is it found in the <name / >and <document />element Which? This tells us about the language used and is found in the <types/> element How? The answer can be found in the <binding /> element. Where? The answer is specified in the <service /> element


Download ppt "Lab Practice 5 Meilan JIANG"

Similar presentations


Ads by Google