Professional Documents
Culture Documents
This document can be used as a tutorial to create web services on the Documentum
Platform. This document will walk you through a web service example, which will
import the content and kick off a workflow using the Documentum Foundation Class
library (DFC). This example can be deployed on all the application servers supported by
Apache SOAP v2.2 runtime. For reference, the deployment and usage of the Apache
Tomcat 3.2 container is explained in this chapter.
What is Workflow?
Workflow is the integral part of a content management solution. Workflow based web
services can be used to create seamless integration between different applications. For
example SAP can use workflow services to kick off different processes in the
Documentum e-Content server as a part of SAP’s workflow. This way we can have an
inter-organization workflow.
A Workflow Workflow D
Client SOAP Web
Service
P F
SAP DCTM
CRM Solutions
Workflow
I Workflow C
Web SOAP Client
Service
In this particular service, a purchase order-processing scenario is used. The web service
client can be written in Visual Basic, Java or another langauge. The client uses an XML
file (called msg1.xml), which contains the meta-data of the content and workflow
template. The meta-data of the purchase order is the information regarding the purchase
order attribute for example price, quantity, item name and so forth. The content can be in
any file format: a word purchase order or scanned purchase order. The web service client
sends the content to the web service server as a MIME attachment to the SOAP envelope.
Once the server receives the SOAP envelope, workflow service will write the SOAP
envelope to a XML file. Also it will store the attachment on the file system. Then it will
import the content in the Docbase using the attributes specified in the SOAP envelope.
After the import operation, the workflow service will start the workflow specified in the
XML file. The content will serve as the package to the workflow process.
Pre-requisites
Because message-oriented services have full control over the SOAP envelopes, any XML
document may be passed as part of the envelope body. When the service receives the
SOAP envelope, it is free to extract the body, and do with it as it pleases.
Following are the major steps to develop the server side implementation of the web
service (Please refer to source code files: workflowTest.java, Dctm_utils.java. These files
can be downloaded from the Developer Program website):
attrs = node.getAttributes();
for (int j = 0; j < attrs.getLength(); j++)
{
attr = attrs.item(j);
package_meta_data.put(attr.getNodeName(),attr.getNodeValue());
}
}
4. Connect to docbase.
//connect to docbase
Dctm_utils util = new Dctm_utils();
session = util.connectToDocbase ("LionelOra1","sachin","****");
//or you can use an ini file to read the docbase connection parameter
Please change the docbase parameters(username,password etc) as per your
configurations.
5. Import the 2nd body part which is the content file attached. The 1st body part is
the SAOP message. The docbase attributes are obtained from the hashtable
which is populated after parsing the XML file(SOAP envelope).
String destionation_folder =
package_meta_data.get("destionation_folder").toString();
// iterate through the files and add only those files that have the
// appropriate properties attached to them i.e. name, format & type.
IDfImportNode node =
(IDfImportNode)importOperation.add(attachment.getAbsolutePath());
node.setNewObjectName(package_meta_data.get("name").toString());
node.setFormat("msw8");
r_object_id = node.getNewObjectId().toString();
IDfWorkflowBuilder workflowBuilder =
session.newWorkflowBuilder( new DfId( processId ) );
// Find the input port. Note that this command can only
// support start activities with a single input port.
int inputPortIndex = 0;
boolean inputPortFound = false;
8. Send the response to the workflow client. In this example, the reponse is just a
string with status of the workflow operation.
If the communications transport which you are using supports two-way interaction, such
as HTTP, then you can use the response context to send a response back to the client. If
you want to send a SOAP Envelope back to the client, you can use the
org.apache.soap.Envelope's marshall(...) method to marshall your envelope to a
java.io.StringWriter, and then invoke the response context's setRootPart(...) method,
passing the StringWriter as the first argument. If you want to send back any other data
types, then you may need to invoke other methods in the response context.
The basic steps for creating a workflow client which interacts with a SOAP message-
oriented workflow service are as follows:
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn:workflowtest" type="message">
<isd:provider type="java"
scope="Application"
methods="startworkflow">
<isd:java class="documentum.workflow.workflowTest" static="false"/>
</isd:provider>
</isd:service>
4. Invoke the send(...) method on the Message object, providing the URL of the
endpoint which is providing the service (i.e.
http://localhost/soap/servlet/messagerouter), the actionURI, and your
envelope.
// Invoke.
msg.send(url, "", msgEnv);
5. If your service is returning data, and assuming that the transport supports
two-way interaction, then you need to retrieve the SOAPTransport object
from the Message object (assuming that you don't already have a handle to
it) by using the getSOAPTransport() method. You can then invoke the
receive() method on the SOAPTransport object to retrieve the returned data.
In this example, web service return a String with all the relevant information like
weather import/workflow was successful or not.
4) To build: Make whatever changes you need to make in the source code.
In the source code directory you will find a build script. Run the script to
build and install the web service client as well as server. The script creates
a staging directory to keep the compiled classes, creates a jar files, copies
the jar files to the %TOMCAT_HOME%\webapps\soap\WEB-INF\classes
directory so that tomcat server can pick it up. Also copies the client
classses to working directory so that testmessaging.cmd script which runs
the client can pick it up.
5) Open command prompt and run $tomcat_home\jakarta-tomcat-
3.2.1\bin\tomcatEnv.bat to set the environment.
6) Create the workflow template you want to use. The r_object_id of the
template corresponds to the processId in the msg1.xml. Also change the
other parameters in the msg1.xml file as per your requirements.
<workflow name="purchase_order"
note="web service test"
processId="4b3cca4c80061ac3"/>
7) Modify the package meta-data as per your requirements. Make sure the
destination_folder already exists in the docbase & it has enough
permissions.
<package location="myfile0"
name="purchase_order.doc"
author="Sachin"
destionation_folder="/sachin/web services/data" />
As you can see, the script first deploys the services and then lists all the services.
One of the services is the workflowtest service. This script calls the workflow
client class with appropriate parameter and deploys the result from workflow
service, then undeploys the service. If you look into the docbase inbox of the
appropriate user, you should see the activity. Also you will find the content file
imported into the specified folder.