Date post: | 26-Dec-2015 |
Category: |
Documents |
Upload: | eustacia-bruce |
View: | 217 times |
Download: | 1 times |
What are Web Services?
Definition of web service A web service is a distributed unit
of business logic that can be accessed over Internet standard web protocols, such as HTTP and that uses XML for sending and receiving messages.
Client Web Service Business Logic
Network Call
Goals of Web Services
To solve interoperability in a platform-neutral way and remove all that mismatches that exist between the various vendors.
To create an abstraction layer between heterogeneous nodes on the network.
To be highly accessible to all platforms through the use of Internets protocols and XML.
To enable interoperability between any type of system.
To provide a solution to bypass firewalls, thus allowing any client to access a remote services.
To take advantage of reduction in communication and server costs.
To advocate designing software as a set of distributed services rather that a component run within a singles process.
Web pages Vs Web servicesCharacteristics Web pages Web services
Transport mechanism
HTTP, SMTP, FTP HTTP, SMTP, FTP
URLs Yes Yes
Message Format HTML XML
Information Type Embedded Data Structured Data
Interactive Yes (DHTML) No
Remote application Communication
No Yes
Platform Neutral Yes Yes
Deployed environment
Web/Application server
Web/Application server
Distributed Model Client/Server P2P
Web service Technology Stack
Discovery
Description
Messaging
Transport
Network
UDDI, DISCO, WSIL, ebXML
WSDL, RDF, ebXML
SOAP, XML-RPC (XML)
HTTP, SMTP, FTP
TCP/IP, UDP
Layer Protocol/ Standard
UDDI : Universal Description Discovery and IntegrationDISCO : Web Service Discovery Tool WSIL : Web Services Inspection LanguageRDF : Resource Description FrameworkUDP : User Datagram Protocol
Web services Architecture
Provider The provider is essentially the company offering a set of
Web Services. Consumer The consumer in P2P model is essentially a client that
can do 2 things; discover and consume set of web services.
Registry This is essentially an XML base repository for business
entities and list of published services offered by organizations.
Consumer Registry
Provider
1. publish
2. Discover
3. Bind
Web Service Development Life-Cycle
Design Figure out what kind of Web Services want to build. Whether
legacy business logic is to be expose or new code should be created or several existing web services should be aggregated to coordinate a business process etc. Decide what kind of tool kits to use and which protocols should be used.
Implementing and Test Create a Web Service server using selected tool kit. Test
interoperability issues between the various toolkits, ex : both PHP and other platforms.
Describe and Deploy Create a description document using WSDL and deploy the
service on server. Publish (Optional) Optionally, your organization may wish to publish your web
service to a UDDI registry. Maintain Ensuring the application is performing, is secure, and that
the developers may implement new features and bug fixes as required.
HTTP
Hyper Text Transfer ProtocolHTTP 1.0HTTP 1.1The default mechanism of
communication for the World Wide Web.
HTTP 1.0 Header
Request Header GET /index.php HTTP/1.0Response Header HTTP/1.0 200 OK Date : Fri, 09 August 2008 11:53:56
GMT Content Length : 152 Content-Type : text/html
HTTP 1.1 Header
Request Header GET /index.php HTTP/1.1 Accept : image/gif, image/jpeg, */* Accept-Language : en-us Accept-Encoding : gzip, deflate User-Agent : Mozilla/4.0 (compatible; MSIE
6.02; windows NT) Host : www.domain.com:80 Connection : Keep-Alive
HTTP 1.1 Header
Response Header HTTP/1.1 200 OK Date : Fri, 09 August 2008 11:53:56 GMT Server : Apache X-Powered-By: PHP/4.4.9 Last-Modified : Thu, 08 August 2008 11:53:56
GMT Content Length : 152 Connection : close Transfer-Encoding : chunked Content-Type : text/html
HTTP methods
Get Post Head The client sends a HEAD request when it wants to see only
the headers of a response, such as Content-Type or Content-Length.
Put Allows a client to place a file on the server and is similar to
sending a file by FTP. Delete The DELETE operation allows a client to remove a
document or Web page from the server. Options The OPTIONS request determines which HTTP methods
the server supports and returns an appropriate header. Trace A TRACE returns the headers sent with the TRACE request
to the client, so that they can be used in debugging.
HTTPS
HTTPS (HTTP over SSL or HTTP Secure) is the use of Secure Socket Layer (SSL) or Transport Layer Security (TLS) as a sub layer under regular HTTP application layering.
HTTPS encrypts and decrypts user page requests as well as the pages that are returned by the Web server.
The use of HTTPS protects against man-in-the-middle attacks.
HTTPS was developed by Netscape.
XML-RPC Overview
XML-RPC Client XML-RPC Server
Web Browser
HTTP
Client make request to the server and fetches request
Browse interacts with HTML based application
Client make request to the server and fetches request
Server receives request and renders response
for client to fetch
•XML-RPC is a remote procedure call protocol encoded in XML•First web service protocol•Use HTTP POST method
XML-RPC Request
POST /web_service_api/xmlrpc_server.php HTTP/1.1User-Agent: PHP/xmlrpc_clientHost: www.domain.comContent-Type: text/xmlContent-Length: 189Connection: Close
<?xml version="1.0" encoding="iso-8859-1"?><methodCall><methodName>hello</methodName><params> <param> <value> <string>XML-RPC</string> </value> </param></params></methodCall>
XML-RPC Request Header
The first linePOST /web_service_api/xmlrpc_server.php HTTP/1.1
The general format is [method][responder][protocol]
The method used here is HTTP POSTThe responder defines how the remote
device should handle the request. Where PHP is concerned, this will be the location and name of the XML-RPC server script
In the protocol field, defined the version of the HTTP using (HTTP 1.0 or HTTP 1.1)
XML-RPC Request Header (Cont)
On the second line User-Agent: PHP/xmlrpc_client
The user agent as a string that identifies the XML-RPC client
Third line Host: www.domain.com
This is used to identify the server to which the request is being sent.
Optionally we can specify a port number hereHost: www.domain.com:8080
XML-RPC Request Header (Cont)
Combining the first and third lines, we have the complete path to our server:www.domain.com/web_service_api/
xmlrpc_server.php On the line four and five, defines the
Content-type, text/xml, and the length of the data being sent to tell the server how much data to except.
XML-RPC Request Header (Cont)
Finally we have the header: Connection: Close
HTTP 1.1 allows for the possibility of the HTTP connection remain open, so we can submit further request. However, a PHP script expecting an FEOF will be waiting indefinitely for the response to finish.
The Payload
The payload contained within a single XML structure: <methodCall>. In side the method call, the method name want to use
along with any associated parameters.<?xml version="1.0" encoding="iso-8859-1"?><methodCall>
<methodName>hello</methodName><params> <param> <value> <string>XML-RPC</string> </value> </param></params>
</methodCall>
XML-RPC ResponseHTTP/1.1 200 OKConnection: Close Content-Length: 189Content-Type: text/xmlDate: Wed, 12 Feb 2006 13:43:03 GTMServer: domain.com/PHP_XMLRPC_SERVER
<?xml version="1.0"?><methodResponse><params> <param> <value> <string>Hello XML-RPC</string> </value> </param></params></methodCall>
XML-RPC data types - Scalars
Data Type XML Tag Example Values
Four-byte signed integer
<i4> or <int> -234, 1435
Boolean <boolean> 0(false) or 1(true)
ASCII String <string> Hello World!
Double precision floating point
<double> -43.342
ISO 8601 Format Date
<dateTime.iso8601>
20060212T12:00:00
Base64-encoded binary
<base64> eW3434DSgDG#$
XML-RPC data types - Arrays
An array are all ways contains a single <data> element, which it self can contains multiple values of any type.<params>
<param> <value>
<array> <data>
<value><double>1.4</double></value> <value><double>3.4</double></value>
</data> </array>
</value> </param>
</params>
XML-RPC data types - Struts Which allow us to constructs similar to an associative array
of named keys and element in PHP.<params> <param> <value> <struct> <member> <name>name</name> <value> <string>John</string> </value> </member> <member> <name>age</name> <value><int>23</int></value> </member> </struct> </value> </param></params>
XML-RPC Fault Response
<?xml version="1.0"?><methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value><string>Too many parameters.</string></value> </member> </struct> </value> </fault> </methodResponse>
• Contains fault code and fault string to identify the errors.• No global list if error messages.• Its up to the developer to assign the fault codes and corresponding fault strings
XML-RPC Introspection Methods
system.listMethods() – Lists currently registered methods
system.describeMethods() – Describes the available methods in detail
system.methodHelp() – Return documentation for a specified methid
systen.methodSignature() – Returns signature for a specific method
system.getCapabilities() – Lists server capabilities
What is SOAP?
SOAP stands for Simple Object Access Protocol SOAP is a communication protocol SOAP is for communication between
applications SOAP is a format for sending messages SOAP communicates via Internet SOAP is platform independent SOAP is language independent SOAP is based on XML SOAP is simple and extensible SOAP allows you to get around firewalls SOAP is a W3C recommendation
SOAP vs XML-RPC
Everything that XML-RPC can do, SOAP does as well.
XML-RPC is much simpler SOAP makes it easier to exchange more
complex documents. SOAP runs over many protocols: HTTP, SMTP, FTP, … SOAP allows developers to create their
own types using XML schemas.