Creating the Web Interface
If our goal is to allow a Word user to create a web posting, you may be wondering why we're introducing a web interface. After all, Content Management Server comes with a robust API, which allows you to perform most of the CMS operations programmatically. Why not write VBA code in Office to handle the integration?
The answer is that the API must run in the context of the ASP engine. In other words, any interaction we have with the CMS server using the API has to be done over the web. The benefit is that our solution will accommodate remote users; essentially, as long as a user can "see" the web server, he or she can contribute a document to the repository. The drawback, however, is that we have to create some sort of web-based interface. For this, we're going to create an ASP page to handle the integration with CMS.
In this solution, the ASP file must collect and set several values:
Description provided by the user and/or document property
The ASP file will have the name of the channel and template required for posting our document; in this example, I've made both of these values constants, so they can be changed easily.
The actual process for the ASP page is as follows:
Create the Autosession object. This is the base object of the CMS API, which is used in most of the steps below.
Advanced users may wonder why I haven't included resolution.inc. This is because this file includes code that redirects users to the manuallogin.asp page, should they not be authenticated. Since you're in Word, this may be a problem. I chose to create the object myself and pass in the credentials.
Assign values to the constants that will point to the channel, template, and document location on the server. Again, I chose to use constants, assuming that documents would always be uploaded to the same channel. However, you could very easily modify the Word interface to allow users to select the location.
Log into the CMS server. In this case, I'm using a very undocumented method of Autosession. For the purposes of this exercise, I've hardcoded the user ID and password. Ideally, you'd either pass this information from values the user entered and/or store encrypted authentication information in the registry. For this exercise, be sure to use the credentials of a CMS author; otherwise, the steps to create a new posting will fail.
Grab the querystring parameters for the filename and description.
Set references to both the channel and template.
Upload the document to the CMS repository using the AcceptBinary method of Autosession.
Create a posting based on the specified template, located in the specified channel.
Change the values for name, display name, and description on the new posting object.
In this new posting, there's a placeholder for an attachment. Modify the value of this placeholder, inserting the URL value retrieved from the AcceptBinary method.
For the displaytext placeholder, insert the description passed in from the document.
Commit the posting to the repository by using the CommitALL method.
Committing specific objects has been deprecated in CMS 2001. The alternative method for committing is CommitALL, which, as the name suggests, commits all transactions in CMS during the current session.
Once the posting has been successfully committed to the repository, submit it for approval.
If your code fails, make sure that the username and password you used are for an author. If this account doesn't have permission to create/modify content, the code won't work properly.
To download the source code for the ASP interface, click here.