SlideShare a Scribd company logo
1 of 26
Created By : Nibha Jain
Web Services
Outlines
What is a Web Service?
Why do we need Web Services?
Types
SOAP vs REST
A Simple Example of SOAP Web Service
WSDL
Web Service Client Example
Queries
What is a Web Service ?
A very simple definition is "a service made available over
the web".
The difference between a standard website and a web
service is this: a website is meant for human consumption, while
a web service is meant for machine (or code)
consumption.
Web services are XML-based information exchange systems
that use the Internet for direct application-to-application
interaction. These systems can include programs, objects,
messages, or documents.
Why do we need
Web Services ?
A Web service is a unit of managed code that can be remotely invoked
using HTTP, that is, it can be activated using HTTP requests. So, Web
Services allows you to expose the functionality of your existing code over
the network. Once it is exposed on the network, other application can
use the functionality of your program.
Web Services allows different applications to talk to each other and
share data and services among themselves. Other applications can also
use the services of the web services. For example VB or .NET application
can talk to java web services and vice versa. So, Web services is used to
make the application platform and technology independent.
Reuse already developed(old) functionality into new software.
Types of Web Services
Simple Object Access Protocol (SOAP)
Representational State Transfer(REST)
In Java we have mainly two types of Web Services :
Types Of Web Services
Simple Object Access Protocol (SOAP)
is a standard protocol
specification for message exchange based on XML.
Communication between the web service and client happens using XML messages.
SOAP defines the rules for communication like
what are all the tags that should be used in XML and their meaning.
Example of SOAP Web
Service
System Requirements:
Java (latest version)
Eclipse (For J2EE developer)
Apache Tomcat (latest version)
Steps for creating web services in eclipse
1. Create new dynamic web project and name it "WebServiceDemo".
2.Create a java file with name ShowProfile and write following code.
3.Right click on project->new->web service
4.Click on next.
5.Click on next , wsdl will be created on WebContent folder.
6.Press finish (You are done with the web service , now you have
Wsdl file which is used to consume web service or say creating a
Client for your web service. )
Before creating the client lets see how the wsdl looks like and what is wsdl ?
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ws.ht.com"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ws.ht.com" xmlns:intf=""
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.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.ht.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getProfile">
<complexType>
<sequence>
<element name="name" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="getProfileResponse">
<complexType>
<sequence>
<element name="getProfileReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="getProfileRequest">
<wsdl:part element="impl:getProfile" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getProfileResponse">
<wsdl:part element="impl:getProfileResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ShowProfile">
<wsdl:operation name="getProfile">
<wsdl:input message="impl:getProfileRequest" name="getProfileRequest">
</wsdl:input>
<wsdl:output message="impl:getProfileResponse" name="getProfileResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
What is wsdl ?
WSDL stands for Web Services Description Language
WSDL is a language for describing how to interface with XML-based services.
WSDL is an integral part of UDDI, an XML-based worldwide business registry.
WSDL is the language that UDDI uses.
WSDL was developed jointly by Microsoft and IBM.
WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'
Definition: element must be the root element of all WSDL documents.
It defines the name of the web service,
declares multiple namespaces used throughout the remainder of the document,
and contains all the service elements described here.
Data types: the data types - in the form of XML
schemas or possibly some other mechanism - to be used in the messages
Message: an abstract definition of the data,
in the form of a message presented either as an
entire document or as arguments to be mapped to a method invocation.
Operation: the abstract definition of the operation for a message,
such as naming a method, message queue, or business process,
that will accept and process the message
Port type : an abstract set of operations mapped to one or more end points,
defining the collection of operations for a binding; the collection of operations,
because it is abstract, can be mapped to multiple transports through various bindings.
Binding: the concrete protocol and data formats
for the operations and messages defined for a particular port type.
Port: a combination of a binding and a network address,
providing the target address of the service communication.
Service: a collection of related end points encompassing
the service definitions in the file; the services map the binding to
the port and include any extensibility definitions.
Following are the elements of WSDL document :
The main structure of a WSDL document looks like this:
<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
<operation>
definition of operation....... <operation>
</portType>
<binding>
definition of a binding....
</binding>
<service>
definition of a service....
</service>
</definitions>
Web Service Client
It can also be referred to as a consumer or requester.
There are many methods/tools/web-tools are available for consuming web service.
Web tools to generate java classes for Android/iPhone for e.g :
l Easywsdl (http://easywsdl.com/)
l Wsdl2code (http://www.wsdl2code.com/pages/home.aspx)
Java Plugins to generate java stub for e.g:
lCXF wsdl2java plugin
lJax-ws
lApache axis2
Step 1 : Open File -> New -> Other... -> Web Services
-> Web ServiceClient
2. Press Next select wsdl.
3.Press Finish.
5. Done !
You can see the generated java classes like this :
Queries
Q. What about security in webservices ?
Ans :When a Web service exposes private-network data to th
outside world, that data travels through four to seven
separate protocol layers (see: TCP/IP or OSI)
thus introducing potential security vulnerabilities.
Implementing security at a higher layer on the protocol s
the application layer,
For instance — generally provides better protection than
implementation at the lower transport layer,
which provides only HTTPS security.
To implement application-layer security,
enable WS-security (a CXF configuration)
on your Web service. WS-security defines
a new SOAP header which is
capable of carrying various security tokens that systems
a Web service caller's identity and privileges.
Q. How to create client from wsdl ?
Ans : There are many tools/web-tools and plugins available to create
client for webservice. Like : Axis2 , JAX-WS
Thank You

More Related Content

What's hot

Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIIMC Institute
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIRajkattamuri
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservicesGagandeep Singh
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentationguest0df6b0
 
Web services
Web servicesWeb services
Web servicesaspnet123
 
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web ServicesIntroduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web Servicesecosio GmbH
 
Cloud computing 22 soap and uddi in services
Cloud computing 22 soap and uddi in servicesCloud computing 22 soap and uddi in services
Cloud computing 22 soap and uddi in servicesVaibhav Khanna
 
Exposing EJBs As Web Services
Exposing EJBs As Web ServicesExposing EJBs As Web Services
Exposing EJBs As Web ServicesSubin Sugunan
 
Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Martin Necasky
 
Web service assignment
Web service assignmentWeb service assignment
Web service assignmentancymary1996
 
web service technologies
web service technologiesweb service technologies
web service technologiesYash Darak
 
Efficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringEfficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringAlexander Decker
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesIMC Institute
 

What's hot (20)

Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservices
 
web technologies Unit 5
 web technologies Unit 5 web technologies Unit 5
web technologies Unit 5
 
Web service architecture
Web service architectureWeb service architecture
Web service architecture
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 
Web Services
Web ServicesWeb Services
Web Services
 
Sia webservices
Sia webservicesSia webservices
Sia webservices
 
Webservices
WebservicesWebservices
Webservices
 
Web service
Web serviceWeb service
Web service
 
Web services
Web servicesWeb services
Web services
 
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web ServicesIntroduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web Services
 
Cloud computing 22 soap and uddi in services
Cloud computing 22 soap and uddi in servicesCloud computing 22 soap and uddi in services
Cloud computing 22 soap and uddi in services
 
Exposing EJBs As Web Services
Exposing EJBs As Web ServicesExposing EJBs As Web Services
Exposing EJBs As Web Services
 
Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)
 
Web service assignment
Web service assignmentWeb service assignment
Web service assignment
 
web service technologies
web service technologiesweb service technologies
web service technologies
 
Web services
Web servicesWeb services
Web services
 
Efficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringEfficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clustering
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 

Similar to Web Services

Web Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptxWeb Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptxssuser403d87
 
Lecture 16 - Web Services
Lecture 16 - Web ServicesLecture 16 - Web Services
Lecture 16 - Web Servicesphanleson
 
Web services Concepts
Web services ConceptsWeb services Concepts
Web services Conceptspasam suresh
 
Dot net training-navimumbai
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbaivibrantuser
 
Web programming
Web programmingWeb programming
Web programmingsowfi
 
webservices overview
webservices overviewwebservices overview
webservices overviewelliando dias
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaJignesh Aakoliya
 
Web services concepts, protocols and development
Web services concepts, protocols and developmentWeb services concepts, protocols and development
Web services concepts, protocols and developmentishmecse13
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications developmentSynapseindiappsdevelopment
 
Web services for developer
Web services for developerWeb services for developer
Web services for developerRafiq Ahmed
 

Similar to Web Services (20)

Webservices
WebservicesWebservices
Webservices
 
Web services
Web servicesWeb services
Web services
 
Web Programming
Web ProgrammingWeb Programming
Web Programming
 
dotNETfinal.ppt
dotNETfinal.pptdotNETfinal.ppt
dotNETfinal.ppt
 
dotNETfinal.ppt
dotNETfinal.pptdotNETfinal.ppt
dotNETfinal.ppt
 
Unit 5 WEB TECHNOLOGIES
Unit 5 WEB TECHNOLOGIES Unit 5 WEB TECHNOLOGIES
Unit 5 WEB TECHNOLOGIES
 
Xml.ppt
Xml.pptXml.ppt
Xml.ppt
 
Web Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptxWeb Services in Cloud Computing.pptx
Web Services in Cloud Computing.pptx
 
Lecture 16 - Web Services
Lecture 16 - Web ServicesLecture 16 - Web Services
Lecture 16 - Web Services
 
Web services Concepts
Web services ConceptsWeb services Concepts
Web services Concepts
 
Dot net training-navimumbai
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbai
 
Web programming
Web programmingWeb programming
Web programming
 
webservices overview
webservices overviewwebservices overview
webservices overview
 
Java web services
Java web servicesJava web services
Java web services
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
Web services concepts, protocols and development
Web services concepts, protocols and developmentWeb services concepts, protocols and development
Web services concepts, protocols and development
 
.NET Tutorial
.NET Tutorial.NET Tutorial
.NET Tutorial
 
Wsdl1
Wsdl1Wsdl1
Wsdl1
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
Web services for developer
Web services for developerWeb services for developer
Web services for developer
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Web Services

  • 1. Created By : Nibha Jain Web Services
  • 2. Outlines What is a Web Service? Why do we need Web Services? Types SOAP vs REST A Simple Example of SOAP Web Service WSDL Web Service Client Example Queries
  • 3. What is a Web Service ? A very simple definition is "a service made available over the web". The difference between a standard website and a web service is this: a website is meant for human consumption, while a web service is meant for machine (or code) consumption. Web services are XML-based information exchange systems that use the Internet for direct application-to-application interaction. These systems can include programs, objects, messages, or documents.
  • 4. Why do we need Web Services ? A Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests. So, Web Services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program. Web Services allows different applications to talk to each other and share data and services among themselves. Other applications can also use the services of the web services. For example VB or .NET application can talk to java web services and vice versa. So, Web services is used to make the application platform and technology independent. Reuse already developed(old) functionality into new software.
  • 5. Types of Web Services Simple Object Access Protocol (SOAP) Representational State Transfer(REST) In Java we have mainly two types of Web Services :
  • 6. Types Of Web Services Simple Object Access Protocol (SOAP) is a standard protocol specification for message exchange based on XML. Communication between the web service and client happens using XML messages. SOAP defines the rules for communication like what are all the tags that should be used in XML and their meaning.
  • 7. Example of SOAP Web Service System Requirements: Java (latest version) Eclipse (For J2EE developer) Apache Tomcat (latest version)
  • 8. Steps for creating web services in eclipse 1. Create new dynamic web project and name it "WebServiceDemo".
  • 9. 2.Create a java file with name ShowProfile and write following code.
  • 10. 3.Right click on project->new->web service
  • 12. 5.Click on next , wsdl will be created on WebContent folder.
  • 13. 6.Press finish (You are done with the web service , now you have Wsdl file which is used to consume web service or say creating a Client for your web service. ) Before creating the client lets see how the wsdl looks like and what is wsdl ?
  • 14. <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://ws.ht.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ws.ht.com" xmlns:intf="" 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.4 Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://ws.ht.com" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="getProfile"> <complexType> <sequence> <element name="name" type="xsd:string"/> </sequence> </complexType> </element> <element name="getProfileResponse"> <complexType> <sequence> <element name="getProfileReturn" type="xsd:string"/> </sequence> </complexType> </element> </schema> </wsdl:types> <wsdl:message name="getProfileRequest"> <wsdl:part element="impl:getProfile" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="getProfileResponse"> <wsdl:part element="impl:getProfileResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="ShowProfile"> <wsdl:operation name="getProfile"> <wsdl:input message="impl:getProfileRequest" name="getProfileRequest"> </wsdl:input> <wsdl:output message="impl:getProfileResponse" name="getProfileResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType>
  • 15. What is wsdl ? WSDL stands for Web Services Description Language WSDL is a language for describing how to interface with XML-based services. WSDL is an integral part of UDDI, an XML-based worldwide business registry. WSDL is the language that UDDI uses. WSDL was developed jointly by Microsoft and IBM. WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'
  • 16. Definition: element must be the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here. Data types: the data types - in the form of XML schemas or possibly some other mechanism - to be used in the messages Message: an abstract definition of the data, in the form of a message presented either as an entire document or as arguments to be mapped to a method invocation. Operation: the abstract definition of the operation for a message, such as naming a method, message queue, or business process, that will accept and process the message Port type : an abstract set of operations mapped to one or more end points, defining the collection of operations for a binding; the collection of operations, because it is abstract, can be mapped to multiple transports through various bindings. Binding: the concrete protocol and data formats for the operations and messages defined for a particular port type. Port: a combination of a binding and a network address, providing the target address of the service communication. Service: a collection of related end points encompassing the service definitions in the file; the services map the binding to the port and include any extensibility definitions. Following are the elements of WSDL document :
  • 17. The main structure of a WSDL document looks like this: <definitions> <types> definition of types........ </types> <message> definition of a message.... </message> <portType> <operation> definition of operation....... <operation> </portType> <binding> definition of a binding.... </binding> <service> definition of a service.... </service> </definitions>
  • 18. Web Service Client It can also be referred to as a consumer or requester. There are many methods/tools/web-tools are available for consuming web service. Web tools to generate java classes for Android/iPhone for e.g : l Easywsdl (http://easywsdl.com/) l Wsdl2code (http://www.wsdl2code.com/pages/home.aspx) Java Plugins to generate java stub for e.g: lCXF wsdl2java plugin lJax-ws lApache axis2
  • 19. Step 1 : Open File -> New -> Other... -> Web Services -> Web ServiceClient
  • 20. 2. Press Next select wsdl.
  • 23. You can see the generated java classes like this :
  • 24. Queries Q. What about security in webservices ? Ans :When a Web service exposes private-network data to th outside world, that data travels through four to seven separate protocol layers (see: TCP/IP or OSI) thus introducing potential security vulnerabilities. Implementing security at a higher layer on the protocol s the application layer, For instance — generally provides better protection than implementation at the lower transport layer, which provides only HTTPS security. To implement application-layer security, enable WS-security (a CXF configuration) on your Web service. WS-security defines a new SOAP header which is capable of carrying various security tokens that systems a Web service caller's identity and privileges.
  • 25. Q. How to create client from wsdl ? Ans : There are many tools/web-tools and plugins available to create client for webservice. Like : Axis2 , JAX-WS