Presentation is loading. Please wait.

Presentation is loading. Please wait.

I hereby declare that this document is based on my project experience. To the best of my knowledge, this document does not contain any material that infringes.

Similar presentations


Presentation on theme: "I hereby declare that this document is based on my project experience. To the best of my knowledge, this document does not contain any material that infringes."— Presentation transcript:

1

2 I hereby declare that this document is based on my project experience. To the best of my knowledge, this document does not contain any material that infringes the copyrights of any other individual or organization including the customers of Infosys. - Aparna Maikkara Introduction to WSDL 2

3 Project Details: Project(s) involved : BOAEASEZ H/W Platform : Windows OS HBU : Enterprise Solutions Target readers: Developers having basic knowledge in XML, XSDKeywords: WSDL WSDL Editors Create WSDL with ALTOVA XML Spy Create WSDL with IBM WebSphere Studio Application Developer Web service Introduction to WSDL 3

4  WSDL - Web Services Description Language  It is used to locate web service and describe operations in that web services as a collection of network endpoints or ports.  WSDL is like a meta data file about web service.  WSDL is an XML document with W3C recommendation.  WSDL file contains details necessary for a service client to invoke methods of a web service. Eg : data types used by methods of web service, method names and signatures, protocols and message formats of methods, network address to access web service etc. Introduction to WSDL 4

5  Major elements in WSDL which describes the web service are Types : data type definitions used by web service Message : definition of messages used by web service Port Type : set of operations performed by one or more end points of web service. Binding : protocol specification for a particular port type of web service Service : specifies the location of web service Introduction to WSDL 5

6  -- definition of data types -- -- definition of a message -- -- definition of a port -- -- definition of a protocols for binding -- -- location of service -- Introduction to WSDL 6

7  Root element in WSDL document is  Defines the name of a web service  targetNamespace attribute of tag specify location where newly created elements exist.  A default namespace will be specified by xmlns="http://schemas.xmlsoap.org/wsdl/" Elements without a namespace prefix like, etc. is assumed to be part of this namespace.  Global namespaces which are referred throughout the WSDL are also declared in this tag.  Consider an example in which a web service “AcademicsApplication” is developed for a school named “ABCSchool” Introduction to WSDL 7

8 <wsdl:definitions name="ABCSchool_AcademicsApplication" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ABCSchool.com/AcademicsApplication" xmlns:ns1="http://ABCSchool.com/data/Student" xmlns:ns2="http://ABCSchool.com/data/ClassMarkList" targetNamespace="http://ABCSchool.com/AcademicsApplication"> Note : soap, xsd, tns, ns1, ns2 are global namespaces In this example, all the WSDL elements will have a namespace prefix ‘wsdl’ which is defined like default namespace. Name of Web service Default namespace Target namespace Introduction to WSDL 8

9  Data types or formats of messages used for communication in web service are defined using XML schema in element.  XML schemas can be imported using ‘import’ element.  Data types are defined in separate elements to increase reusability of same data types among multiple web services  Consider the previous example “AcademicsApplication” Processes offered by this web service are  Retrieving student mark list of a class. Input Parameters : Standard and division Output Parameters : Student Id, Student Name and Marks  Adding a student to a particular class. Input Parameters : Student Id, Student Name, Student Age, Standard and division For execution of these processes, messages are sent and received by web service. The structure of these messages are specified using XML schema. Introduction to WSDL 9

10 <wsdl:types> <tns:schema elementFormDefault="qualified" targetNamespace="http://ABCSchool.com/AcademicsApplication" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://ABCSchool.com/data/Student" /> <import namespace="http://ABCSchool.com/data/ClassMarkList" /> <element name="ClassDetails"> <complexType> <sequence> <element name=”Standard” type=”string” minOccurs=“1” /> <element name=”Division” type=”string” minOccurs=“1” /> </sequence> </complexType> </element> </schema> <wsdl:types> Note: imported namespaces are the locations where data types or element structures used in this web service other than the elements defined in <types> tag resides. Default namespace Imported namespaces XML schema of an Element Introduction to WSDL 10

11  Messages sent or received by web service providers and consumers are given in element.  Input and output message structures of each operation of a web service is linked with the data types defined in tag.  element can appear any number of times in a WSDL.  consists of two sections  Name : logically represents name of a message for each operation. It is specified inside ‘name’ attribute of tag  Part : links the data element to which the message is referring to.  The message structure of each message will be explained by elements specified under ‘Part’ section of message tag. These elements will be already defined under tag. Introduction to WSDL 11

12 <tns:schema elementFormDefault="qualified" targetNamespace="http://ABCSchool.com/AcademicsApplication" xmlns="http://www.w3.org/2001/XMLSchema"> Introduction to WSDL 12 Message Name Element Name getMarkListIn is the input message sent to the web service inorder to retrieve marklist of an entire class. The data format of this message is described by the element “ClassDetails” defined inside tag of WSDL

13 getMarkListOut is the output message sent back from the web service which contains marklist of an entire class. The data format of this message is described by the element “ClassMarkList” defined inside xml schema imported from the location "http://ABCSchool.com/data/ ClassMarkList" (import statement in given inside tag of WSDL) getMarkListIn is the input message sent to the web service inorder to retrieve marklist of an entire class. The data format of this message is described by the element “ClassDetails” defined inside tag of WSDL addStudentIn is the input message sent to the web service to add a student to a particular class. The data format of this message is described by the element “Student” defined inside xml schema imported from the location "http://ABCSchool.com/data/Student" (import statement in given inside tag of WSDL) Introduction to WSDL 13

14  operations of a web service is described under tag.  Port can be defined as the end point by which web service is connected.  maps each of the operation with type of messages sent and received by a web service.  Types of Operation available are  One-way The operation that accepts a message but will not return a response.  Request-response The operation that returns a response for the requests accepted by it.  Solicit-response The operation that waits for a response after sending a request.  Notification The operation that send a message but will not wait for a response Introduction to WSDL 14

15 Note : getMarkList is a Request-Response operation (It accepts the class details and returns the markList) addStudent is a One-way operation (It accepts the student details, but it doesn’t return any value) An optional element ‘fault ’ can be declared to set the format of message to be sent back in case of errors. It is defined inside tag as Port name Operation name to retrieve mark list Operation name to add a student Input and output message structures for retrieving marklist Input message structure to add a student Introduction to WSDL 15

16  element specifies protocol details of a web service.  It links message format to a network protocol by portType and operations  Binding element has two attributes name : binding name is defined type : binding port is defined.  Most commonly used binding type is SOAP.  SOAP binding element has two attributes style : ‘rpc’ or ‘document’ transport : defines the protocol used for connecting to web service. HTTP protocol, WMQ(WebSphere Message Queue) protocol, SMTP protocol etc.  Multiple bindings can be specified for a single portType Introduction to WSDL 16

17 Note : port name defined in portType is specified inside the type attribute of HTTP binding is specified for "AcademicsApplicationPortType" with HTTP transport protocol is used in this example. If WMQ transport is to be used, define transport= " http://www.ibm.com/xmlns/prod/wmq/transport " Operation name and corresponding input/output messages are linked with HTTP protocol Introduction to WSDL 17

18  element contains location details of a web service.  Service tag has two sub sections Documentation – It gives a description of web service for the user. Port - It specifies the port through which the web service can be accessed. Each port will be having a name and it is associated with a binding.  Structure of service tag is as follows description of web service Introduction to WSDL 18

19 Web service developed for ABC School  Name of the service is given inside ‘name’ attribute of service tag.  contains the school details for which this web service is developed  AcademicsApplicationPort is the port name for connecting this web service.  AcademicsApplicationHTTPBinding is the binding type associated with port name AcademicsApplicationPort (AcademicsApplicationHTTPBinding is specified in tag of WSDL)  In this example, the web service AcademicsApplication is located at http://ABCSchool.com/service/  If MQBinding is used, the location of service will be specified by queue and queue manager names location="wmq:/msg/queue/Queue_name@Queue_manager_name" Introduction to WSDL 19

20 Go to File>New and select wsdl from the menu shown below. Introduction to WSDL 20

21  Following WSDL structure will be created by default.  Switch to ‘Text’ view to edit  By default fig(1) will be existing in WSDL. Edit the document to add required namespaces as in fig(2) Fig(1) Fig(2) Introduction to WSDL 21

22  Go to WSDL view and double click on title bar of NewPortType and edit the portType name. Introduction to WSDL 22

23  Edit operation Name by double clicking on NewOperation under AcademicsApplicationPortType.  Rename NewOperation to getMarkList Introduction to WSDL 23

24  Right click on the green and blue arrow shown on he left side of operation Name getMarkList to select the type of operation.  Edit operation Name by double clicking on NewOperation under AcademicsApplicationPortType. Introduction to WSDL 24

25  To append an operation, right click on operation bar of portType and select operation type Introduction to WSDL 25

26  Expand the operation tab to edit input and output messages.  Double click on message names and parameters to edit it. Introduction to WSDL 26

27  Double click on binding name and edit.  Rename ‘NewBinding’ to ‘AcademicsApplicationHTTPBinding’ as shown below. Introduction to WSDL 27

28  To add a new binding, right click on empty area and select ‘Insert Binding’ Introduction to WSDL 28

29  click the down arrow in title bar of the Binding box and select the required protocol (here soap12)  Select data format of the operation (rpc or doc) from the drop down on the right side of operation.  Double click and edit soapaction  Edit names of Input and Output messages if required Introduction to WSDL 29

30  Validate WSDL by selecting XML>Validate XML from Menu or by pressing F8  Validation results are displayed in Validation output bar below the Main window.  Type of error and ways to resolve it will be displayed in this window  If the XML is valid, a tick mark will be displayed in a green circle. Otherwise a window similar to the one shown below will be displayed. Introduction to WSDL 30

31 Introduction to WSDL 31 Go to File>New and select XML Choose WSDL from sub pane on the right as shown below and click Next

32 Introduction to WSDL 32 Choose the folder in which WSDL file has to be created. Give Filename and click Next

33 Introduction to WSDL 33 Choose the folder in which WSDL file has to be created. Give Filename and click Next

34 Introduction to WSDL 34 Give the target Namespace and select Namespace URIs to be included.

35 Introduction to WSDL 35 Give the target Namespace and select Namespace URIs to be included. Click Finish to create Sample.wsdl

36 Introduction to WSDL 36 After creating Sample.wsdl, below screen will be visible in ‘Graph’ view

37 Introduction to WSDL 37 Right click on Types and select Add Child > Schema Right click on the schema added and select ‘Add Global Element’ to add an element.

38 Introduction to WSDL 38 To edit the element details, fill appropriate columns as shown below.

39 Introduction to WSDL 39 To add a message to WSDL, Right click on Messages and select Add Child>Message Any number of messages can be added in the same way.

40 Introduction to WSDL 40 Fill the message name in ‘New Message’ window

41 Introduction to WSDL 41 To add a part to a message, right click on the required message and select Add Child>Part Give appropriate name for new Part in ‘New Part’ window

42 Introduction to WSDL 42 To define element of the part created, right click on part (i.e. Input) and select Set Element. To create New element, choose ‘Create a new element’ and fill appropriate element details. To select an existing element, choose ‘Select an existing element’ and choose the required element from the sub pane as shown below.

43 Introduction to WSDL 43 After creating Message, below screen will be visible in ‘Graph’ view

44 Introduction to WSDL 44 To add a Port Type to WSDL, Right click on ‘Port Types’ and select Add Child>Port Type Fill appropriate port type name in ‘New Port Type’ window To add an operation to the newly added port, right click on port type and select Add Child >Operation and give appropriate name to new operation

45 Introduction to WSDL 45 Add Input, Output and Fault messages to operation by selecting message type from right click menu pane To specify a message type to Input /Output /Fault of an operation, right click on Input /Output /Fault and select ‘Set Message’. Select existing message from ‘Specify Message’ window

46 Introduction to WSDL 46 After selecting existing message to operation, link will appear between Port Types and Messages as shown below

47 Introduction to WSDL 47 To add a Binding to WSDL, Right click on ‘Bindings’ and select Add Child>Binding. Fill in Appropriate name for Binding and choose appropriate Port Type and Protocol in Binding Wizard.

48 Introduction to WSDL 48 After selecting existing port type to binding, link will appear between Bindings and Port Types as shown below

49 Introduction to WSDL 49 To add a Service to WSDL, Right click on ‘Services’ and select Add Child>Service Fill in Appropriate name for service in ‘New Service’ window

50 Introduction to WSDL 50 To add a Port to a service, Right click on newly created service and select Add Child>Port Fill in Appropriate name for port in ‘Port Wizard’ window. Select appropriate binding, protocol and fill in location of service.

51 Introduction to WSDL 51 After selecting existing port binding to newly added port, link will appear between Services and Bindings as shown below

52 Introduction to WSDL  soapUI – for generating WSDL interfaces http://www.soapui.org/Getting-Started/your-first-soapui-project.html  Eclipse WTP WSDL Editor http://wiki.eclipse.org/index.php/Introduction_to_the_WSDL_Editor  WSCF - Web services Contract-First http://www.thinktecture.com/Resources/Software/WSContractFirst/WSCF04Walkt hrough1.html 52

53 Introduction to WSDL  http://www.w3schools.com/wsdl/wsdl_documents.asp  http://manual.altova.com/xmlspy/spyenterprise/index.html?xswsdlsoap.htm  http://www.tutorialspoint.com/wsdl/wsdl_references.htm  http://www.w3.org/TR/wsdl 53

54


Download ppt "I hereby declare that this document is based on my project experience. To the best of my knowledge, this document does not contain any material that infringes."

Similar presentations


Ads by Google