.NET API For Stellent / Oracle Content Server

Stellent / Oracle Content Sever has a wonderful component which allows you wrap a WSDL around any of the app’s services.  It’s pretty easy to use and has made Visual Studio(at least for me), my preferred IDE for writing ad-hoc and batch applications.  In fact I have to confess that I’ve found it much simpler to write simple batchloading programs in .NET rather then using Stellent’s own batchloading tool.

Despite my personal fandom of the WSDL component, it does have a couple drawbacks:

1.  Each web service is in it’s own namespace.  This makes it a bit of a pain when working with multi-step operations, for instance if you’re calling the DocInfo service with a WSDL it will return all custom metadata in an array of IdcProperty objects.  If you’re then planning on updating that item or checking in another related item, you’ll have to copy all your original IdcProperty objects over to new IdcProperty objects specific to the Checkin/Update service’s namespace.

2.  Aside from the seven or so pre-defined services, you have to define any additional WSDLS you wish to consume.  Not the end of the world, but it does make the development a little tricker when you need ensure your WSDL exists on each instance you connect to and that it’s defined to your specs.

There is an alternative; rather then using the WSDLs, you could just add IsSoap=1 to the end of any service call, which will then return you request in SOAP format.  Of course there’s no friendly WSDL to create all your proxy classes, leaving the SOAP parsing up to you.  In addition uploading files can also be pretty tricky as you essentially need to replicate a multi-part/form upload.

To make my life(and potentially yours) a little easier, I’ve been experimenting and ultimately developed a simple .NET API for the Stellent / Oracle Content Server.  Modeled after the Stellent’s Java-based idcserver package, the API can make IsSoap service calls to retrieve information, or just straight HTTP calls when downloading files.  In addition since all calls are made as multipart-form/data posts, one to many files may be uploaded and checked in.

The API has two public classes, the ServerBean which is the primary interface to the API and the ServerResultSet class which acts and behaves like a Stellent Resultset.  If you think you’ve seen those class names before, it’s because you have.  I tried to replicate the functionality of the Content Server’s idcserver package in .NET.

Here’s an example of a search results call using the API:

//create the object
ServerBean sb = new ServerBean();
//set the url to the content server
sb.ContentServerURL = "http://localhost/stellent/idcplg";
//set our credentials
sb.ContentServerCredentials = new System.Net.NetworkCredential("sysadmin", "idc");
//set the service
sb.putLocal("IdcService", "GET_SEARCH_RESULTS");
//pass in our query
sb.putLocal("QueryText", "dDocTitle <substring> `Test`");
//execute the service
sb.executeService();
//get our search results
ServerResultSet SearchResults = sb.getResultSet("SearchResults");
if (SearchResults != null)
{
  //loop through the search results
  for(SearchResults.first();SearchResults.isRowPresent();SearchResults.next()){
  //write the content id
  System.Diagnostics.Debug.WriteLine(SearchResults.getStringValue("dDocName"));
  }
}
 

As you can see the syntax is extremely similar to the Content Server’s idcserver package.  Anyone familier with JSP development in the content server, should find it very familiar.

Uploading files is also very easy.  I’ve overriden the “putLocal” method so that it can accept a string or a FileInfo object as a value argument.

//create the object
ServerBean sb = new ServerBean();
//set our url
sb.ContentServerURL = "http://localhost/stellent/idcplg";
//set our credentials
sb.ContentServerCredentials = new System.Net.NetworkCredential("sysadmin", "idc");
//service is a check in new
sb.putLocal("IdcService", "CHECKIN_NEW");
//set the title and required arguments
sb.putLocal("dDocTitle", "NET TEST CHECKIN");
sb.putLocal("dDocType", "Document");
sb.putLocal("dDocAuthor", "sysadmin");
sb.putLocal("dSecurityGroup", "Public");
//create to fileinfo objects based on some local files
System.IO.FileInfo File1 = new System.IO.FileInfo(@"C:\Test Spreadsheet.xls");
System.IO.FileInfo File2 = new System.IO.FileInfo(@"C:\Test Text File.txt");
//add the files
sb.putLocal("primaryFile", File1);
sb.putLocal("alternateFile", File2);
//execute the service
sb.executeService();
//check our status
Console.WriteLine(sb.getLocal("StatusMessage"));

Since we also need to download files or retrieve raw results like a dynamic conversion, the underlying executeServiceEx method which is called by the executeService method and also returns a raw stream from the Content Server’s response is a public method.  Calling executeServiceEx directly will skip the lines of code realted to parsing the server’s response.

In this example, we perform a dynamic conversion and write the raw HTML to the console window

//Create the object
ServerBean sb = new ServerBean();
//set the url
sb.ContentServerURL = "http://localhost/stellent/idcplg";
//set our credentials
sb.ContentServerCredentials = new System.Net.NetworkCredential("sysadmin", "idc");
//set the dynamic conversion
sb.putLocal("IdcService", "GET_DYNAMIC_CONVERSION");
//set our required parameters
sb.putLocal("dDocName", "[Content ID]");
sb.putLocal("RevisionSelectionMethod", "LatestReleased");
//call executeServiceEx, which returns the raw stream
Stream resultStream = sb.executeServiceEx();
//create a reader
System.IO.StreamReader reader = new System.IO.StreamReader(resultStream);
//read the stream
String resultString = reader.ReadToEnd();
//write it to the console
Console.Write(resultString);

That’s the basic gist on how to work with the API, I will be following up this post with one going through the actual code.  Like any of my code examples, the API is provided without support or warrenty, but I plan keeping the API as sort of a a personal ongoing project so you can expect future versions and enhancements.  If you have any questions or ideas please let me know.  I’m really looking for some feedback on this one, so comment away.

I’ve bundled the source as well as an installer package together and posted them for download here.  Once installed the API will appear in your Visual Studio add references dialog as OUCSNET.

.NET API For Stellent / Oracle Content Server

About David Roe

Thanks for visiting ContentOnContentManagment.com, my name is David Roe and this is my blog. I work for Ironworks Consulting as a technical lead/architect in our enterprise content management group. My primary focus is implementing Oracle Universal Content Server, which was formerly known as Stellent Content Server. Prior to focusing in Stellent, my work centered around .NET integrations with other content managment systems as well as content management systems built on the .NET framework. I plan on keeping this blog mostly technical in nature. I’m not really one for the Coke vs. Pepsi debates, so plan on seeing quite a bit of ”how to” content. Please feel free to download and use any of the code examples available on the site. As you might imagine none of it is supported or warented..do we need a disclaimer? I do ask that you leave any references to me or this site in the comments though.
This entry was posted in .NET, C#, Oracle, Stellent, Web Service. Bookmark the permalink.

Comments are closed.