Developing Web Services - Dell EMC · PDF file• SOAP • HTTP POST with ... • RPC...

41

Transcript of Developing Web Services - Dell EMC · PDF file• SOAP • HTTP POST with ... • RPC...

Developing Web ServicesLalith Subramanian and

Don Robertson

Agenda• What are Web Services?

• Definition• Supporting technologies• High-level architecture• Benefits

• Why should we be interested?• Industry-wide buzz• Opportunities

• Building Web Services on top of Documentum• Summary

Agenda• What are Web Services?

• Definition• Supporting technologies• High-level architecture• Benefits

• Why should we be interested?• Industry-wide buzz• Opportunities

• Building Web Services on top of Documentum• Summary

Definition

• A well-defined set of operations that are network accessible using standardized technologies

• Just as XML is the universal data representation, so Web Services will become the universal behavioral representation

Sample Services

• B2B Arena• Hardware manufacturer reseller chain• Web services to monitor sales at resellers• Web services to source manufacturing to multiple

providers

• Consumer Arena• Web Services automatically searched to find nearest

photo printing service

Enabling Technologies

• XML• Universal structured data representation

• HTML for humans (B2C), XML for automation (B2B)

• HTTP• Universal transport• Firewall friendly• Payload agnostic

• HTTP + XML = transport + payload

Web Service Technologies

• SOAP• HTTP POST with XML envelope as payload• Standardized payload envelope• Service addressability

• WSDL• Web Services Description Language

• UDDI• Universal Description, Discovery, and Integration

High-LevelArchitecture

Find/L

ocate

Publish Listing

Registry ServiceDescription

ServiceDescription

Provider

ServiceDescription

ServiceImplementation

Requestor

ServiceDescription

Bind/Invoke

The Participants

Internet

Requestor

HTTP Server

SOAP Router

Implementation

Browser

Java Program

.NET Program

Requestor Provider

Architectural Flexibility

• Interaction Styles• Request/response or One-way• RPC or Message-style

• Transports• HTTP• SMTP• MOM (Message Oriented Middleware)

Platform Independence

• Vendor / Application software-neutral• Language neutral• Transport neutral• Widely available infrastructure• Endpoints are free to differ

• Loosely coupled

Agenda• What are Web Services?

• Definition• Supporting technologies• High-level architecture• Benefits

• Why should we be interested?• Industry-wide buzz• Opportunities

• Building Web Services on top of Documentum• Summary

The Industry Buzz

• IBM, Microsoft, and Sun all agree!• So do we• Great minds seldom differ ☺

• Significant vendor investment• Sun One, .NET, etc.

• Mindshare• Documentum eContent Services initiative

Why the Momentum?

• XML content enables automated consumption• Facilitated by schema standards

• Promotes efficiency by automation• easy to measure in B2B scenarios

• Content is more dynamic• Provision of services via the Web• J2EE & .NET coexistence (inevitable)

What’s in It for Me?• High leverage due to ease of reuse• If you’re in an IT department

• Offer Web Services to your business units• Based on re-purposable services provided by your

organization

• e.g., PDF rendering and archival service

• If you’re a Documentum partner• componentize your value-added offerings• offer as web services yourself or license

Agenda• What are Web Services?

• Definition• Supporting technologies• High-level architecture• Benefits

• Why should we be interested?• Industry-wide buzz• Opportunities

• Building Web Services on top of Documentum• Summary

WS on Documentum ECM Platform

• Great Web Service characteristics• Fast connections in eContent Server 4.2• XML capabilities• Scalability!

• Write a service in Java using DFC• Consider message-oriented services with content• Let wizards help you with RPC-like services

• Remember: You can implement on one platform, consume on another

Starting to Build Web Services

• Well-encapsulated business logic• You may already have this

• Depending on available skills• Tools from IDE or application server vendor

• Service generation from EJBs, .NET components• BEA WebLogic, IBM WebSphere, Visual Studio .NET

• Simple-to-use, but not completely flexible

• Raw SOAP, WSDL, UDDI toolkits• Most flexible, but requires more code development• Most macho way to do things ☺

HTTP vs. JMS(or Even SMTP)

• HTTP• assumes service availability• no guaranteed delivery

• JMS• quality of service choices• allows asynchronous service availability• can implement as message-driven bean

• SMTP possible too

RPC vs. Message-Oriented

• RPC• less code• IDE wizard support

• Message-oriented• NOT talking about MOM transports!• coding is more manual (but simple)• easier to handle attachments• appropriate for one-way services

Stateless vs. Session Preserving

• Stateless• the default model

• Session preserving • available in some app servers• allows some state • HTTP only

Dynamic Discovery vs. Early Binding

• Dynamic Binding• Publish services to the world• Exploit external implementations

• Early Binding• UDDI? Don’t worry about it initially.• Easier to code• .NET and app server default

Preparation

• Getting started• Download a toolkit (Apache is free)• Use your app server/toolkit wizards• Skip UDDI for now

• Install Tomcat (currently 3.2)• Install Apache SOAP (currently 2.2)

SOAP envelope

Message-Style Services With Documentum

Document(s) as Attachment

Documentum specific service parameters

• Treat content as an attachment(s) • Use simple XML for service parameters• NOT talking about MOM (e.g., MQSeries)!

HTTP Server

SOAP Router

Wrapper(unmarshall)

Web ServiceImplementation

WorkflowInitiationwith DFC

An Example(Workflow)

Internet

Client

Document as Attachment

SOAP Envelope

DocumentumWorkflowparameters

Web ServiceImplementation

Standard Prototype

public void startWorkflow(Envelope envelope, SOAPContext requestContext,SOAPContext responseContext)

throws IOException,MessagingException,SAXException,Exception;

HTTP Server

SOAP Router

Wrapper(unmarshall)

WorkflowInitiationwith DFC

• Provide SOAP interface to DFC-based business logic

Extract DCTM Request Details

Web ServiceImplementation

HTTP Server

SOAP Router

WorkflowInitiationwith DFC

Wrapper(unmarshall)

// Extract workflow details from XML documentMimeBodyPart rootPart =

requestContext.getRootPart();String xml = rootPart.getContent().toString();StringReader reader = new StringReader(xml);DocumentBuilder xmldb =

XMLParserUtils.getXMLDocBuilder();Document doc =

xmldb.parse(new InputSource(reader));

// … process DOM document

Extract Attachment

// Extract MIME messageMimeBodyPart bp = requestContext.getBodyPart(1);

// Unpack MIME package// Content type: bp.getContentType() // Content-ID: bp.getContentID() // Content-Location: bp.getHeader( // org.apache.soap.Constants.HEADER_CONTENT_LOCATION,// null) // Separate out file that we will route// Filename: bp.getFileName() // Content: bp.getContent().toString()

// Now standard DFC manipulation ...

// ... send responseresponseContext.setRootPart(response, "text/xml");

Service

HTTP Server

SOAP Router

WorkflowInitiationwith DFC

Wrapper(unmarshall)

Apache Deployment

HTTP Server

Wrapper(unmarshall)

Web ServiceImplementation

WorkflowInitiationwith DFC

<isd:service xmlns:isd="http://xml.apache.org/xml-

soap/deployment"id="urn:workflow" type="message">

<isd:provider type="java"scope="Application"methods="startWorkflow">

<isd:javaclass=”com.documentum.ws.Workflow”static="false"/>

</isd:provider></isd:service>

SOAP Router

• Describes service to request dispatcher

Java Client-Side Implementation

// Build the SOAP message.Message msg = new Message();

// Add the document as an attachment.ByteArrayDataSource ds =

new ByteArrayDataSource("MyAttachment.txt"), null);DataHandler dh = new DataHandler(ds);MimeBodyPart bp = new MimeBodyPart();bp.setDataHandler(dh);bp.setFileName("MyAttachment.txt");bp.setHeader(

org.apache.soap.Constants.HEADER_CONTENT_LOCATION,"MyAttachment");

msg.addBodyPart(bp);

• Gory details of client code to invoke service• Typically handled by IDE-based code generator

Marshal Documentum

Parameters// Build the workflow service parameters.String workflowParameters =

"<package size=\"" + ds.getSize() + "\""+ "location =\"MyAttachment\""+ "name =\"MyAttachment.txt\"/>”;

String processId = "4b3cca4c80061ac3";String workflow = "purchase_order";workflowParameters +=

"<workflow processId=\"" + processId + "\""+ "note =\"web service test\"”+ "name =\"" + workflow + "\"/>”;

• Packaging of service-specific parameters• In this example, router id, attachment, etc.

Embed Within SOAP Message

// Construct SOAP messageString xml ="<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";xml += "<s:Body>";xml += "<startWorkflow xmlns=\"urn:startWorkflow\">";xml += workflowParameters;xml += "</startWorkflow>";xml += "</s:Body>";xml += "</s:Envelope>";

Issue Web Service Request

// Issue Web Service request.StringReader reader = new StringReader(soapXML);DocumentBuilder xmldb = XMLParserUtils.getXMLDocBuilder();Document doc = xmldb.parse(new InputSource(reader));Envelope envelope =

Envelope.unmarshall(doc.getDocumentElement());

msg.send(messageRouterUrl, "", envelope);

Agenda• What are Web Services?

• Definition• Supporting technologies• High-level architecture• Benefits

• Why should we be interested?• Industry-wide buzz• Opportunities

• Building Web Services on top of Documentum• Summary

The Future• Web Services Workflows

• WSFL• essential for service orchestration

• Schemas have to evolve• for true interoperability

• Widespread UDDI registration• Private / Public registries

• Standard service descriptions• ebXML?

Will Web Services be the new EDI?

• Platform neutrality• Convergence with ebXML• Low cost of entry

• Microsoft is ready• So tools will be excellent

• IDEs will dramatically simplify development• Automated deployment of EJBs as services

So...

• Don’t get left behind!• Free tools• Easy to implement• Documentum ECM platform offers many

WS opportunities!

References

• www.documentum.com/products/webservices.html• www.webservices.org• ibm.com/developerworks/webservices• dcb.sun.com/practices/webservices• msdn.microsoft.com/soap• msdn.microsoft.com/webservices• www.soapware.com• www.bea.com/products/weblogic/server/J2EE_Web_Ser

vices_WP.pdf

Other Presentations

• Documentum connector to EJBs• Excellent overview on using JDBC to build

transactional EJBs to deploy as services• Vaughn Vernon, CCC

• Web Development Environment• Kevin O’Connor, Documentum

Presentations on the Momentum Live

Web Site

To access this presentation (beginning later today):

Web site: www.momentumlive.comPassword: orlando2002