54
Introduction to WSDL & WSDL Editors

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

Embed Size (px)

Citation preview

Slide 1

Introduction to WSDL & WSDL EditorsDeclaration: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 MaikkaraIntroduction to WSDL2Project Details:Project(s) involved : BOAEASEZH/W Platform : Windows OSHBU : Enterprise Solutions

Target readers:Developers having basic knowledge in XML, XSD

Keywords: WSDL WSDL EditorsCreate WSDL with ALTOVA XML Spy Create WSDL with IBM WebSphere Studio Application DeveloperWeb service

Introduction to WSDL3IntroductionWSDL - 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 WSDL4WSDL Document StructureMajor elements in WSDL which describes the web service are

Types : data type definitions used by web serviceMessage : definition of messages used by web servicePort Type : set of operations performed by one or more end points of web service.Binding : protocol specification for a particular port type of web serviceService : specifies the location of web service

Introduction to WSDL5Sample WSDL Structure

-- definition of data types --

-- definition of a message --

-- definition of a port --

-- definition of a protocols for binding --

-- location of service --

Introduction to WSDL6DEFINITIONSRoot 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 ABCSchoolIntroduction to WSDL7DEFINITIONS

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 serviceDefault namespaceTarget namespaceIntroduction to WSDL8TYPESData types or formats of messages used for communication in web service are defined using XML schemain 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 AcademicsApplicationProcesses offered by this web service are Retrieving student mark list of a class.Input Parameters : Standard and divisionOutput Parameters : Student Id, Student Name and Marks

Adding a student to a particular class. Input Parameters : Student Id, Student Name, Student Age, Standard and divisionFor execution of these processes, messages are sent and received by web service.The structure of these messages are specified using XML schema.

Introduction to WSDL9TYPES

Note: imported namespaces are the locations where data types or element structures used in this web service other than the elements defined in tag resides.Default namespaceImported namespacesXML schema of an Element Introduction to WSDL10MESSAGEMessages 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 sectionsName : logically represents name of a message for each operation. It is specified inside name attribute of tagPart : 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 WSDL11

MESSAGEIntroduction to WSDL12Message NameElement NamegetMarkListIn 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 WSDLgetMarkListOut 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) MESSAGE

Port nameOperation name to retrieve mark list Operation name to add a studentInput and output message structures for retrieving marklistInput message structure to add a studentIntroduction to WSDL15BINDING 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 definedtype : binding port is defined.

Most commonly used binding type is SOAP.

SOAP binding element has two attributes style : rpc or documenttransport : 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 portTypeIntroduction to WSDL16

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"BINDINGOperation name and corresponding input/output messages are linked with HTTP protocolIntroduction to WSDL17SERVICE element contains location details of a web service.

Service tag has two sub sectionsDocumentation 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

Introduction to WSDL18SERVICE 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 nameslocation="wmq:/msg/queue/Queue_name@Queue_manager_name"

Introduction to WSDL19Create WSDL using ALTOVA XML SpyGo to File>New and select wsdl from the menu shown below.

Introduction to WSDL20Create WSDL using ALTOVA XML Spy 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 WSDL21Edit PortType Go to WSDL view and double click on title bar of NewPortType and edit the portType name.

Introduction to WSDL22Edit Operation Edit operation Name by double clicking on NewOperation under AcademicsApplicationPortType.

Rename NewOperation to getMarkList

Introduction to WSDL23Append an operation 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 WSDL24Append an operation To append an operation, right click on operation bar of portType and select operation type

Introduction to WSDL25Add Messages to an operation Expand the operation tab to edit input and output messages.

Double click on message names and parameters to edit it.

Introduction to WSDL26Create binding Double click on binding name and edit.

Rename NewBinding to AcademicsApplicationHTTPBinding as shown below.

Introduction to WSDL27Create binding

To add a new binding, right click on empty area and select Insert BindingIntroduction to WSDL28Select Protocol and Data formatclick 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 requiredIntroduction to WSDL29Validate the WSDL document 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 WSDL30Create WSDL using IBM WebSphere Studio Application DeveloperIntroduction to WSDL31Go to File>New and select XMLChoose WSDL from sub pane on the right as shown below and click Next

Create WSDL fileIntroduction to WSDL32Choose the folder in which WSDL file has to be created.Give Filename and click Next

Create WSDL fileIntroduction to WSDL33Choose the folder in which WSDL file has to be created.Give Filename and click Next

Define NamespacesIntroduction to WSDL34Give the target Namespace and select Namespace URIs to be included.

Define NamespacesIntroduction to WSDL35Give the target Namespace and select Namespace URIs to be included.Click Finish to create Sample.wsdl

Sample.wsdlIntroduction to WSDL36After creating Sample.wsdl, below screen will be visible in Graph view

Add TypesIntroduction to WSDL37

Right click on Types and select Add Child > SchemaRight click on the schema added and select Add Global Element to add an element.Add TypesIntroduction to WSDL38

To edit the element details, fill appropriate columns as shown below.Add MessagesIntroduction to WSDL39

To add a message to WSDL, Right click on Messages and select Add Child>MessageAny number of messages can be added in the same way.Add MessagesIntroduction to WSDL40

Fill the message name in New Message windowAdd MessagesIntroduction to WSDL41

To add a part to a message, right click on the required message and select Add Child>PartGive appropriate name for new Part in New Part windowAdd MessagesIntroduction to WSDL42

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.Add MessagesIntroduction to WSDL43

After creating Message, below screen will be visible in Graph viewAdd PortIntroduction to WSDL44

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 operationAdd PortIntroduction to WSDL45

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 windowAdd PortIntroduction to WSDL46

After selecting existing message to operation, link will appear between Port Types and Messages as shown belowAdd BindingIntroduction to WSDL47

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.Add BindingIntroduction to WSDL48

After selecting existing port type to binding, link will appear between Bindings and Port Types as shown belowAdd ServiceIntroduction to WSDL49

To add a Service to WSDL, Right click on Services and select Add Child>Service

Fill in Appropriate name for service in New Service windowAdd ServiceIntroduction to WSDL50

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.

Add ServiceIntroduction to WSDL51

After selecting existing port binding to newly added port, link will appear between Services and Bindings as shown belowOther WSDL editor tools for creating WSDLIntroduction to WSDLsoapUI for generating WSDL interfaceshttp://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-Firsthttp://www.thinktecture.com/Resources/Software/WSContractFirst/WSCF04Walkthrough1.html52ReferencesIntroduction to WSDLhttp://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/wsdl53Thank you