Consumers of the Web Services Framework
| January 2007 | |
| Contributed by - Fabian Lee (fabian.lee@flatironssolutions.com), Flatirons Solutions Corporation |
Abstract
With the release of 5.3 and the Web Services Framework (WSF), Documentum has provided the tools to develop and deploy web services with a minimal learning curve. However, the system documentation focuses on the web service provider, and does not go into detail on developing the consumer. The client consumer is an essential part of the web service equation, and can be a challenge for the developer or integrator who is tasked with generating the initial proof-of-concept for an external group, often in a non-Java programming language.In this article, I will focus on the consumer side of web services and detail the steps needed to generate web service clients in Java, C#, VB.NET, Visual Basic for Applications, and Perl.
Table of Contents
Before you Begin
The Web Services Framework Development Guide
is an excellent introduction to developing and deploying web services using the WSF. This guide offers two web service providers that
we will use extensively throughout this article:
-
Hello service - a simple greeting service that returns a variation on the message provided
-
RepoAccessor service - offers repository import and export functionality
Both these providers can be copied and pasted directly from the guide. This article assumes you have deployed both these services, and
now need to create a suitable client. Throughout this article I assume that your WSF installation can be found at http://localhost:8080/ws.
Java Client
While it is entirely possible to write a web service client using only raw socket calls, this would definitely be a chore considering
all the network communication and marshalling that goes into even a simple web service. Fortunately, Axis provides us with a tool
called WSDL2Java which can take a web service definition and create all the supporting classes needed to make calls to a web service.
To run this utility against the DocbaseCredentials service (installed by default in WSF), use the following command from the console:
java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/ws/services/DocbaseCredentials?wsdl
|
This command can be run from the Windows command line as long as axis.jar is included in the classpath. Axis is installed with Application Builder or
the WSF,
and is referenced from dctm.jar. Running the command will generate the following client classes:
-
com.documentum.ws._2005.framework.DocbaseAuthenticationFailure.java
-
com.documentum.ws._2005.framework.DocbaseCredentials.java
-
com.documentum.ws._2005.framework.DocbaseCredentialsInfo.java
-
com.documentum.ws._2005.framework.DocbaseCredentialsService.java
-
com.documentum.ws._2005.framework.DocbaseCredentialsServiceLocator.java
-
com.documentum.ws._2005.framework.DocbaseCredentialsSoapBindingStub.java
-
com.documentum.ws._2005.framework.WebServiceException.java
This package is directly related to the namespace
specified in the WSDL, http://documentum.com/ws/2005/framework.
The java classes in this directory depend upon the SOAP libraries and dependencies, and so you must compile them against the jars which
are located in the WEB-INF\lib directory of the WSF web application. Below is a test program that exercises the generated code
for the DocbaseCredentials service.
import com.documentum.ws._2005.framework.*; // DocbaseCredentials
public class TestDocbaseCredentials {
public static void main(String args[]) throws Exception {
if(args.length<3) {
System.out.println("Usage: docbase user pass");
System.exit(1);
}
String repository = args[0];
String domain = "";
String username = args[1];
String password = args[2];
// web service locator
DocbaseCredentialsServiceLocator credentialsLocator = new DocbaseCredentialsServiceLocator();
credentialsLocator.setMaintainSession(true);
// fill credentials object
DocbaseCredentials credentials = credentialsLocator.getDocbaseCredentials();
DocbaseCredentialsInfo info = new DocbaseCredentialsInfo(repository, domain, password, username);
// call web service and display token
String token = credentials.newCredentials(info, true);
System.out.println("Acquired Token=" + token);
}
}
|
The DocbaseCredentials service generates a token that can then be used for authentication when invoking other web services.
To illustrate the use of this token, we will use the example Hello service provided in Chapter two of the
Web Services Framework Development Guide.
This example depends on the fact that you deployed the Hello service exactly as provided in the documentation,
being sure to use the same namespace they specify (the screenshot is a little blurry in the documentation):
http://myorg.com/ws/2005/services
|
Once again, run the WSDL2Java tool, this time against the Hello service definition.
java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/ws/services/Hello?wsdl
|
This will generate the client side stub code. Now we can write a test program for the Hello service:
import com.documentum.ws._2005.framework.*; // DocbaseCredentials
import com.myorg.ws._2005.services.*; // Hello service
import org.apache.axis.message.*; // SOAP Header
public class TestHello {
public static void main(String args[]) throws Exception {
if(args.length<3) {
System.out.println("Usage: docbase user pass");
System.exit(1);
}
String repository = args[0];
String domain = "";
String username = args[1];
String password = args[2];
// get token from Docbase Credentials service
DocbaseCredentialsServiceLocator credentialsLocator = new DocbaseCredentialsServiceLocator();
credentialsLocator.setMaintainSession( true);
DocbaseCredentials credentials = credentialsLocator.getDocbaseCredentials();
DocbaseCredentialsInfo info = new DocbaseCredentialsInfo(repository, domain, password, username);
String token = credentials.newCredentials(info, true);
System.out.println("Acquired Token=" + token);
// setup hello service
HelloServiceLocator hloc = new HelloServiceLocator();
hloc.setHelloEndpointAddress("http://localhost:8080/ws/services/Hello");
HelloSoapBindingStub hstub = (HelloSoapBindingStub) hloc.getHello();
// set token header
String namespace = "http://localhost:8080/ws/2005/services";
SOAPHeaderElement header = new org.apache.axis.message.SOAPHeaderElement(
namespace, "DocumentumSecurityToken"
);
header.setPrefix("");
header.setActor(javax.xml.soap.SOAPConstants.URI_SOAP_ACTOR_NEXT);
javax.xml.soap.SOAPElement element = header.addChildElement("token");
element.addTextNode(token);
hstub.setHeader(header);
// call Hello service
System.out.println("Calling Hello service = " + hstub.greet("my test"));
}
}
|
The code for this test class is similar to the previous example, except for the portion that sets the token value in the SOAP header.
This is needed for authentication by the WSF framework, and establishes a connection using the original IDfSessionManager.
Base 64 in Java
Since SOAP messaging is XML-based, binary content cannot be included in the message structure (binary content can cause XML to be malformed).
But similar to other internet protocols such as SMTP, web services can circumvent this limitation by relying on Base 64 encoding.
The Base 64 encoding scheme chunks data into 6 bit values, which adds overhead to the data load but in exchange makes binary content safe
for text transfer.
The problem for developers seems to be choosing the best library for Base 64 manipulation. Using Java, the best option is to use the facilities
provided by Axis. Lisa Hill has written an excellent article for
dmdevleoper.com that outlines the exact steps for both encoding and decoding in the Base 64 format.
I mimicked her techniques to produce the following example using the RepoAccessor service.
Base 64 Decoding
Use the following code to retrieve content from the
repository and write it to a file called c:\test.bin.
// RepoAccessor web service
RepoAccessorServiceLocator serviceLocator = new RepoAccessorServiceLocator();
serviceLocator.setMaintainSession(true);
RepoAccessorSoapBindingStub rstub = (RepoAccessorSoapBindingStub) serviceLocator.getRepoAccessor();
rstub.setHeader(header);
// call to web service
String id = "0900............";
byte[] sourceArr = rstub.exportObjectXferBase64(id, repo);
// decode data, write to file
String dataString = new String(sourceArr);
byte[] destArr = org.apache.axis.encoding.Base64.decode(dataString);
FileOutputStream fos = new FileOutputStream("c:/test.bin");
fos.write(destArr);
fos.close();
|
Base 64 Encoding
To import content into the repository, you must encode a byte array using Base 64.
// read file data
File file = new File("C:/test.bin");
FileInputStream stream = new FileInputStream(file);
int size = stream.available();
byte[] bytes = new byte[size];
stream.read(bytes);
stream.close();
// convert to base 64
String encDataString = org.apache.axis.encoding.Base64.encode(bytes);
byte[] data = encDataString.getBytes();
// call to web service
if(rstub.importFileXferBase64(data, "/Temp", repository)) {
System.out.println("Just imported into the /Temp cabinet");
}else {
System.err.println("Failed to import into the /Temp cabinet");
}
|
C# Client
Generating a C# web service consumer is very convenient when using Visual Studio's wizard interface. First create a new project called TestWSClient.
The first service we want to add to the project is DocbaseCredentials. From the "References" node
of the solution explorer, right click and select "Add Web Reference".
Use
http://localhost:8080/ws/services/DocbaseCredentials?wsdl as the URL and use "cr" as the web reference name.
Now go ahead and do this twice more to bring in references to the Hello and RepoAccessor services.
Here is the information used to fill out the wizard pages:
-
Hello - url=http://localhost:8080/ws/services/Hello?wsdl, refname=hello
-
RepoAccessor - url=http://localhost:8080/ws/services/RepoAccessor?wsdl, refname=repo
Now our client code to connect to the repository and invoke the Hello service looks like this:
// Instantiate the credentials service
cr.DocbaseCredentialsService crServ = new cr.DocbaseCredentialsService();
// Instantiate and populate credentials info
cr.DocbaseCredentialsInfo info = new cr.DocbaseCredentialsInfo();
info.docbaseName = "mydocbase";
info.user = "dmadmin";
info.password = "dmadmin";
// Obtain a security token
String token = crServ.newCredentials(info, true);
Console.WriteLine("token=" + token);
// Instantiate Hello service
hello.HelloService myHello = new hello.HelloService();
// Instantiate a Hello service security token
// and set its value to the token that
// the credentials service returned
hello.DocumentumSecurityToken hsToken = new hello.DocumentumSecurityToken();
hsToken.token = token;
// Set the token value for the SOAP header
myHello.DocumentumSecurityTokenValue = hsToken;
// Execute the business logic
Console.WriteLine(myHello.greet("my test"));
|
Base 64 in C#
C# has built in functions for working with Base 64, which makes life easier than the other languages presented here, but still requires a little work.
Base 64 Decoding
// Instantiate repoaccessor service
repo.RepoAccessorService reposvc = new repo.RepoAccessorService();
repo.DocumentumSecurityToken repoToken = new repo.DocumentumSecurityToken();
repoToken.token = token;
reposvc.DocumentumSecurityTokenValue = repoToken;
String id = "0900............";
String repo = "mydocbase";
String filename = "C:\\test.bin";
// call web service export
byte[] b64 = reposvc.exportObjectXferBase64 (id, repo);
System.Console.WriteLine ("Exported " + id + " as Base64 byte array of size=" + b64.Length);
// decode base 64
String str64 = System.Text.Encoding.UTF8.GetString (b64);
byte[] b = Convert.FromBase64String(str64);
// write decoded data to file
FileStream file = new FileStream(filename,FileMode.OpenOrCreate,FileAccess.ReadWrite);
file.Write(b,0,b.Length);
file.Close();
|
Base 64 Encoding
// read data from file
file = new FileStream(filename,FileMode.OpenOrCreate,FileAccess.Read);
BinaryReader br = new BinaryReader(file);
b = new byte[file.Length];
byte[] tempbuf = new byte[2048];
int res = -1;
int count=0;
while(res!=0)
{
res = br.Read(tempbuf,0,2048);
if(res>0)
{
Array.Copy(tempbuf,0,b,count,res);
count+=res;
}
}
br.Close();
Console.WriteLine("read in " + count + " bytes for import");
// now that we have built a byte array, lets convert to base64
String s64 = Convert.ToBase64String (b);
b64 = System.Text.Encoding.UTF8.GetBytes (s64);
String repoPath = "/Temp";
// call import web service
if (reposvc.importFileXferBase64 (b64,repoPath,repo))
{
System.Console.WriteLine ("Successfully imported file to " + repoPath);
}
else
{
Console.WriteLine("problem importing " + filename + " to repository");
}
|
VB.NET Client
Creating and using a VB.NET client is almost exactly like C#. For that reason, I will provide only a brief set of instructions for
this section, and instead refer the reader back to the C# client for fleshing out the full solution.
First create a new project called TestVBClient.
The first service we want to add to the project is DocbaseCredentials. From the "References" node
of the solution explorer, right click and select "Add Web Reference".
Use
http://localhost:8080/ws/services/DocbaseCredentials?wsdl as the URL and use "cr" as the web reference name.
Now go ahead and do this twice more to bring in references to the Hello and RepoAccessor services.
Here is the information used to fill out the wizard pages:
-
Hello - url=http://localhost:8080/ws/services/Hello?wsdl, refname=hello
-
RepoAccessor - url=http://localhost:8080/ws/services/RepoAccessor?wsdl, refname=repo
Now our client code to connect to the repository and invoke the Hello service looks like this:
Module Module1
Sub Main()
Dim crSrv As cr.DocbaseCredentialsService = New cr.DocbaseCredentialsService
Dim cred As cr.DocbaseCredentialsInfo = New cr.DocbaseCredentialsInfo
cred.docbaseName = "mydocbase"
cred.user = "dmadmin"
cred.password = "dmadmin"
Dim token As String
token = crSrv.newCredentials(cred, True)
Console.WriteLine("token=" & token)
' call the hello service
Dim helloSrv As hello.HelloService = New hello.HelloService
Dim helloToken As hello.DocumentumSecurityToken = New hello.DocumentumSecurityToken
helloToken.token = token
helloSrv.DocumentumSecurityTokenValue = helloToken
Console.WriteLine(helloSrv.greet("my test"))
End Sub
End Module
|
Base 64 in VB.NET
Here is a snippet of code that demonstrates calling the RepoAccessor service and
doing basic Base 64 manipulation.
Dim crSrv As cr.DocbaseCredentialsService = New cr.DocbaseCredentialsService
Dim cred As cr.DocbaseCredentialsInfo = New cr.DocbaseCredentialsInfo
cred.docbaseName = "mydocbase"
cred.user = "dmadmin"
cred.password = "dmadmin"
Dim token As String
token = crSrv.newCredentials(cred, True)
Console.WriteLine("token=" & token)
Dim raSrv As ra.RepoAccessorService = New ra.RepoAccessorService
raSrv.Url = "http://localhost:8080/ws/services/RepoAccessor"
Dim raToken As ra.DocumentumSecurityToken = New ra.DocumentumSecurityToken
raToken.token = token
raSrv.DocumentumSecurityTokenValue = raToken
Dim id As String
id = "0900............"
Dim barr() As Byte
barr = raSrv.exportObjectXferBase64(id, "mydocbase")
' byte arr to string
Dim str As String
str = System.Text.Encoding.UTF8.GetString(barr)
' decode base64 string
Dim barrdec() As Byte
barrdec = System.Convert.FromBase64String(str)
|
As stated earlier, see the C# Client section for more information.
VBA Client
Most people don't think of Microsoft Word or Excel as a web service client, but that is exactly what
the Office XP Web Services Toolkit available
from Microsoft provides (free download).
This capability is exciting because it offers the typical user unprecedented access to live information in the repository. Imagine:
- Updating a column in a spreadsheet, which would immediately modify attributes in the repository
- Synchronizing a financial spreadsheet with the most accurate data available in the repository
- Pushing fresh content to webpublisher by simply saving a document
I think this is one of the most exciting client access methods in this article because it has so many potential uses. And since the
user does not need the DFC installed on the local client machine it truly puts the power in the hands of the business users.
The tricky part of making this work with the WSF is getting the authentication token in the SOAP header and handling Base 64 encoding. Let me explain how to do this from MS Excel, it
should work the same way in MS Word.
1. Install the Office XP Web Services Toolkit
If you are not using Windows XP, you will need to download the Office XP Web Services Toolkit and install it.
2. Open the VBA Editor
Select "View" from the menu, then "Toolbars" > "Visual Basic"
Then click on the "VBA Editor" button
3. Add the Web References
Then add a reference to the DocbaseCredentials service.
Use http://localhost:8080/ws/services/DocbaseCredentials?wsdl as the URL.
Pressing the "Add" button will generate several class modules which are proxies to the actual web service. Repeat this same
process and add the Hello and RepoAccessor services.
-
Hello http://localhost:8080/ws/services/Hello?wsdl
-
RepoAccessor http://localhost:8080/ws/services/RepoAccessor
4. Modify the Generated Client Code
The client code generated by the Office XP WS Toolkit does not support the DCTM authentication
tokens sent in the header of the SOAP message. In order to make the client work, we have to override the default behavior for handling
the SOAP header. This can be done by overriding the
IHeaderHandler class used by the SoapClient30 object.
The IHeaderHandler class is an interface, so we select "Insert" > "Class Module" from the menu and create our own
implementation of the interface class that generates a security token in the header. By default, this Class module will be named "Class1". Rename it to
AuthHeader in the properties window by selecting the module node in the Project
Explorer and then selecting "View" > "Properties Window" from the menu.

The code for this new class is below.
Option Explicit
Implements IHeaderHandler
Private TokenStr As String
Public Property Let Token(ByRef Val As String)
TokenStr = Val
End Property
Public Property Get Token() As String
Token = TokenStr
End Property
Private Sub Class_Initialize()
Token = "not intialized"
End Sub
Public Function IHeaderHandler_readHeader(
ByVal par_Reader As MSSOAPLib30.ISoapReader,
ByVal par_HeaderNode As MSXML2.IXMLDOMNode,
ByVal par_Object As Object) As Boolean
IHeaderHandler_readHeader = True
End Function
Private Function IHeaderHandler_willWriteHeaders() As Boolean
IHeaderHandler_willWriteHeaders = True
End Function
Private Sub IHeaderHandler_WriteHeaders(ByVal par_Serializer As MSSOAPLib30.ISoapSerializer,
ByVal par_Object As Object)
' <soap:Header>
' <DocumentumSecurityToken xmlns="http://myorg.com/ws/2005/services">
' <token>..../token>
' </DocumentumSecurityToken>
'</soap:Header>
par_Serializer.StartHeaderElement "DocumentumSecurityToken", "http://myorg.com/ws/2005/services"
par_Serializer.StartElement "token"
par_Serializer.WriteString TokenStr
par_Serializer.EndElement
par_Serializer.EndHeaderElement
End Sub
|
Then the web service client needs to be told to use the new header functionality. The following code needs to be inserted into the clws_HelloService class module. This allows us
to set both the token property and our custom header handler.
' private field which holds security token
Private TokenStr As String
' property setter which also adds custom handler
Public Property Let Token(ByRef Val As String)
TokenStr = Val
Dim theHeader As AuthHeader
Set theHeader = New AuthHeader
If (theHeader Is Nothing) Then
MsgBox "nothing"
Else
theHeader.Token = TokenStr
End If
' set custom header handler for <b>hello</b> service
Set sc_HelloService.HeaderHandler = theHeader
End Property
Public Property Get Token() As String
Token = TokenStr
End Property
|
This same pattern is used to modify the clws_RepoAccessorService class module
' private field which holds security token
Private TokenStr As String
' property setter which also adds custom handler
Public Property Let Token(ByRef Val As String)
TokenStr = Val
Dim theHeader As AuthHeader
Set theHeader = New AuthHeader
If (theHeader Is Nothing) Then
MsgBox "nothing"
Else
theHeader.Token = TokenStr
End If
' set custom header handler for <b>repoaccesor</b> service
Set sc_RepoAccessorService.HeaderHandler = theHeader
End Property
Public Property Get Token() As String
Token = TokenStr
End Property
|
5. Create the Macro
Select "Insert" > "Module" from the VBA Editor menu to create a macro, and paste
in the following code. You can run this macro by selecting "Tools" > "Macros" from the menu in
the VBA editor or MS Excel. This simple client code pops up a message box with the returned
value of the web service, but could just as easily populate data in the spreadsheet.
Sub testHello()
' get docbase credentials
Dim crSrv As New clsws_DocbaseCredentialsSer
Dim cred As New struct_DocbaseCredentialsIn
With cred
.docbaseName = "mydocbase"
.user = "dmadmin"
.password = "dmadmin"
End With
Dim token As String
token = crSrv.wsm_newCredentials(cred, True)
MsgBox "token=" & token
' call hello service
Dim hSrv As New clsws_HelloService
hSrv.token = token
MsgBox hSrv.wsm_greet("test this")
End Sub
|
Enable Macros
You may need to change the security permissions within Excel to run the macro. You can change this from
"Tools" > "Option" > "Security" tab > "Macro Security" button.
Base 64 in VBA
Base 64 decoding in VBA requires writing custom functions unless you want to use COM or ActiveX libraries. I
recommend the custom function approach because it keeps the Office document free of dependencies that would dilute
the solution.
Below is the code for accessing content using the RepoAccessor service. For brevity, I
am not going to copy the full Base 64 class module or supporting functions. You can find the full code in the
supplementary download provided with this article.
Sub testRepoAccessor()
' get docbase credentials
Dim b64 As Base64Class
Set b64 = New Base64Class
Dim crSrv As New clsws_DocbaseCredentialsSer
Dim cred As New struct_DocbaseCredentialsIn
With cred
.docbaseName = "mydocbase"
.user = "dmadmin"
.password = "dmadmin"
End With
Dim token As String
token = crSrv.wsm_newCredentials(cred, True)
' set token of repoAccessor service
Dim raSrv As New clsws_RepoAccessorService
raSrv.token = token
' set parameters and call export web service
Dim idstr As String
idstr = "0900271080011fbb"
Dim Base64() As Byte
Base64 = raSrv.wsm_exportObjectXferBase64(idstr, "mydocbase")
' decode byte array and write to file
Dim base64Str As String
base64Str = ByteArrayToString(Base64)
Open "C:\test.dec.bin" For Binary Access Write As #1
Put #1, , b64.DecodeToByteArray(ReplaceCharacters(base64Str, Chr(10), ""))
Close #1
' read binary file
Dim abBytes() As Byte
Dim lFileLength As Long
Dim str As String
Open "c:\test.dec.bin" For Binary Access Read As #1
lFileLength = LOF(1)
ReDim abBytes(lFileLength)
Get #1, , abBytes()
Close #1
' encode bytes and import to docbase
str = b64.EncodeByteArray(abBytes)
abBytes = StringToByteArray(str)
If (raSrv.wsm_importFileXferBase64(abBytes, "/Temp", "mydocbase")) Then
MsgBox "Import Successful"
Else
MsgBox "Import failed"
End If
End Sub
|
6. Perl Client
We will use the SOAP::Lite module for calling web services from Perl. Here is
the code needed to call the Hello service.
#!perl
use SOAP::Lite;
# get credentials token using subroutine
my $cred = getToken();
# setup header to hello service
my $header = SOAP::Header->name(DocumentumSecurityToken => {
Token => $cred
});
my @params = ($header);
# setup hello service
my $soap = SOAP::Lite
-> service('http://localhost:8080/ws/services/Hello?wsdl');
# set param and call web service
$msg = SOAP::Data->name("in1" => "test this")->type('');
print $soap->greet($msg,@params) . "\n";
# return to console
exit(1);
################ SUBS ###################################
# subroutine for getting the docbase credentials token
sub getToken() {
#setup parameters to credentials service
$in0 = SOAP::Data
->name("in0" => \SOAP::Data->value(
SOAP::Data->name("docbaseName" => 'mydocbase')->type(''),
SOAP::Data->name("domain" => '')->type(''),
SOAP::Data->name("user" => 'dmadmin')->type(''),
SOAP::Data->name("password" => 'dmadmin')->type(''),
))
;
$in1 = SOAP::Data->name("in1" => "true")->type('');
$agg = SOAP::Data->value(
$in0,
$in1
);
# make call to credentials service
my $cred = SOAP::Lite
-> service('http://localhost:8080/ws/services/DocbaseCredentials?wsdl')
-> newCredentials($agg);
print "Token=$cred\n";
return $cred;
}
|
Base 64 in Perl
Base 64 encoding in Perl is available through the MIME::Base64 module. If this module is not available
on your local system, you can install it with the following command from the console.
perl -MCPAN -e "install MIME::Base64"
|
We will use two specific subroutines from this module, decode_base64 and
encode_base64 for calling the import and export functions of the RepoAccesor service.
The following code will call both the import and export functionality of the RepoAccessor service. Of particular
interest in this code is the need to Base 64 encode/decode twice in order to prepare the data. This is the result of the WSF sending the
data in a generic string type.
#!perl
use SOAP::Lite;
use MIME::Base64;
# get credentials token using subroutine
my $cred = getToken();
# setup header
my $header = SOAP::Header->name(DocumentumSecurityToken => {
Token => $cred
});
my @params = ($header);
# export parameters
$exportparams = SOAP::Data->name("in0" =>
SOAP::Data->value(
SOAP::Data->name("in0" => '0900271080011fbb')->type(''),
SOAP::Data->name("in1" => 'mydocbase')->type(''),
)
);
# call export web service
my $soap = SOAP::Lite
-> service('http://localhost:8080/ws/services/RepoAccessor?wsdl');
my $data = $soap->exportObjectXferBase64($exportparams,@params);
# decode data and write to file
my $str = decode_base64(decode_base64($data));
print "exported file of length=".length($str)."\n";
# write decoded binary to file
open(FILE, ">c:\\perl.dec.bin");
binmode(FILE);
print FILE $str;
close(FILE);
# import parameters
$importparams = SOAP::Data->name("in0" =>
SOAP::Data->value(
SOAP::Data->name("in0" => encode_base64(encode_base64($str)) )->type(''),
SOAP::Data->name("in1" => '/Temp')->type(''),
SOAP::Data->name("in2" => 'mydocbase')->type(''),
)
);
# call import web service
$soap = SOAP::Lite
-> service('http://localhost:8080/ws/services/RepoAccessor?wsdl');
my $res = $soap->importFileXferBase64($importparams,@params);
if($res) {
print "Successfully imported file to /Temp cabinet\n";
}else {
print "Problem importing to repository\n";
}
# return to console
exit(1);
################ SUBS ###################################
# subroutine for getting the docbase credentials token
sub getToken() {
#setup parameters to credentials service
$in0 = SOAP::Data
->name("in0" => \SOAP::Data->value(
SOAP::Data->name("docbaseName" => 'mydocbase')->type(''),
SOAP::Data->name("domain" => '')->type(''),
SOAP::Data->name("user" => 'dmadmin')->type(''),
SOAP::Data->name("password" => 'dmadmin')->type(''),
))
;
$in1 = SOAP::Data->name("in1" => "true")->type('');
$agg = SOAP::Data->value(
$in0,
$in1
);
# make call to credentials service
my $cred = SOAP::Lite
-> service('http://localhost:8080/ws/services/DocbaseCredentials?wsdl')
-> newCredentials($agg);
print "Token=$cred\n";
return $cred;
}
|
Download Source
The code referenced in this article is zipped up for your convenience.
About the Author
 |
Fabian Lee has over 10 years experience as a software engineer and consultant,
and has been assisting customers with technical and business solutions based on Documentum for over six years. His clients have
included some of the leading names in the airline, finance, insurance, health, government, and IT sectors. Fabian currently works as
a consultant at Flatirons Solutions Corporation, focusing on their government ECM solutions in the Washington, D.C. area.
Fabian started working with the WDK at version 1.0.1, and has written customizations for each major version since. An
avid open-source enthusiast, he works on several community projects including the Repository Interrogation Tool.
|
References
Related Articles
Inside the Web Services Framework, Fabian Lee
Securing the Web Services Framework, Fabian Lee
Using the 5.3 Web Services Framework, Lisa Hill
Perl
SOAP::Lite
SOAP Libraries and Axis Engine
Axis Home Page
EMC Documentum Technical Publications
WSF Development Guide
|