Web Services Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.
Objectives Web Services 1.What is WS? 2.How does it work? 3.WS in Action 4.An Example in Liferay
What is WS? WS = Web Services A software system designed to support interoperable Machine to Machine interaction over a network (W3C). Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.
What is WS? Web services platform elements SOAP (Simple Object Access Protocol) – XML plus HTTP UDDI (Universal Description, Discovery and Integration) - a directory service where businesses can register and search for Web services. WSDL (Web Services Description Language) - an XML-based language for describing Web services and how to access them.
What is WS? Additional specifications, WS-* WS-Security - Defines how to use XML Encryption and XML Signature in SOAP to secure message exchanges. WS-Reliability - An OASIS standard protocol for reliable messaging between two Web services. WS-Reliable Messaging - A protocol for reliable messaging between two Web services. WS-Addressing - A way of describing the address of the recipient (and sender) of a message. WS-Transaction - A way of handling transactions.
How WS Works Service Registry Service Requestor Service Provider Bind Find Publish
How WS Works Styles of use Remote procedure calls (RPC) - RPC Web services present a distributed function (or method) call interface that is familiar to many developers. Typically, the basic unit of RPC Web services is the WSDL operation. Service-oriented architecture (SOA) - The basic unit of communication is a message, rather than an operation - "message-oriented" services. Representational state transfer (REST)- RESTful Web services attempt to emulate HTTP and similar protocols by constraining the interface to a set of well- known, standard operations (e.g., GET, PUT, DELETE).
Web Services in Action HTTP, HTTPS, SMTP XML, SOAP, Addressing XSD,WSDL,UDDI,Policy,Metadata Exchange BPEL4WS / WS-BPEL Transports Messaging Transports Composable service assurances Transactions Reliable messaging Security
WSDL & SOAP & UDDI What is it? –WSDL 1.1 Good specification –WSDL 2.0 Much better specifications –JSR 110: Java APIs for WSDL –SOAP 1.1 / 1.2 –UDDI 1.0 / 2.0 / 3.0
An Example in Liferay Alfresco Content UI: Add content: Alfresco Content Link: com.liferay.portlet.alfrescocontent.util.AlfrescoContentUtil org.alfresco.webservice.* at alfresco_client.jar URL: PropsUtil.ALFRESCO_CONTENT_SERVER_URL; Page: portal/portal-web/html/portlet/alfresco_content/init.jsp Portlet Type: Struts portlet at portal/portal-ejb/src com.liferay.portlet.alfrescocontent.action com.liferay.portlet.alfrescocontent.util
An Example in Liferay Code Review – at source-ws/AlfrescoContentUtil.java AuthenticationUtils.startSession(userId, password); RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService(); Reference reference = null; if (Validator.isNull(uuid)) { reference = new Reference(_SPACES_STORE, null, null); } else { reference = new Reference(_SPACES_STORE, uuid, null); } QueryResult result = repositoryService.queryChildren(reference); ResultSetRow[] rows = result.getResultSet().getRows();
Review of WS WS - Secure, Reliable, Transacted. –Transports - HTTP, HTTP/S, SMTP –Message Formats – XSD –WS-Addressing WS - a Service-Oriented Architecture. –Services are described by schema and contract not type –Service compatibility is more than type compatibility –Service-orientation assumes that bad things can and will happen –Service-orientation enables flexible binding of services WS-BPEL, BPEL4WS: see next topic
Revision History Jonas Yuan05/30/07Created for Liferay 4.2.2