web services copyright © 2000-2007 liferay, inc. all rights reserved. no material may be reproduced...

13
Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.

Upload: abel-brabazon

Post on 01-Apr-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

Web Services

Copyright © 2000-2007 Liferay, Inc.

All Rights Reserved.No material may be reproduced electronically or in print without written

permission from Liferay, Inc.

Page 2: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

Objectives

Web Services

1. What is WS?

2. How does it work?

3. WS in Action

4. An Example in Liferay

Page 3: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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.

Page 4: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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.

Page 5: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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.

Page 6: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

How WS Works

Service Registry

Service Requestor

Service ProviderBind

Find Publish

Page 7: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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).

Page 8: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

Web Services in Action

HTTP, HTTPS, SMTP

XML, SOAP, Addressing

XSD,WSDL,UDDI,Policy,Metadata Exchange

BPEL4WS / WS-BPEL

Transports

Messaging

Transports

Transports

Composable service

assurancesTransactions

Reliablemessaging

Security

Page 9: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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

Page 10: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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

Page 11: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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();

Page 12: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

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

Page 13: Web Services Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission

Revision HistoryJonas Yuan 05/30/07 Created for Liferay 4.2.2