Developing Web Services Lalith 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-Level Architecture Registry Service Description Service Description Service Description Find/Locate Bind/Invoke Publish Listing Service Description Service Implementation Requestor Provider
The Participants Requestor Provider Browser Internet HTTP Server Java Program Requestor SOAP Router.NET Program Implementation
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)
Message-Style Services With Documentum SOAP envelope Documentum specific service parameters Document(s) as Attachment Treat content as an attachment(s) Use simple XML for service parameters NOT talking about MOM (e.g., MQSeries)!
An Example (Workflow) Client SOAP Envelope Documentum Workflow parameters Document as Attachment Internet Web Service Implementation HTTP Server SOAP Router Wrapper (unmarshall) Workflow Initiation with DFC
Standard Prototype public void startworkflow( Envelope envelope, SOAPContext requestcontext, SOAPContext responsecontext) throws IOException, MessagingException, SAXException, Exception; Web Service Implementation HTTP Server SOAP Router Wrapper (unmarshall) Provide SOAP interface to DFC-based business logic Workflow Initiation with DFC
Extract DCTM Request Details // Extract workflow details from XML document MimeBodyPart 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 Web Service Implementation HTTP Server SOAP Router Wrapper (unmarshall) Workflow Initiation with DFC
Extract Attachment // Extract MIME message MimeBodyPart bp = requestcontext.getbodypart(1); Service // 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 response responsecontext.setrootpart(response, "text/xml"); HTTP Server SOAP Router Wrapper (unmarshall) Workflow Initiation with DFC
Apache Deployment <isd:service xmlns:isd="http://xml.apache.org/xmlsoap/deployment" id="urn:workflow" type="message"> <isd:provider type="java" scope="application" methods="startworkflow"> <isd:java class= com.documentum.ws.workflow static="false"/> </isd:provider> </isd:service> Web Service Implementation HTTP Server SOAP Router Wrapper (unmarshall) Workflow Initiation with DFC 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 message String 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.com Password: orlando2002