Accessing the MSCMS Publishing API in Perl (302206)



The information in this article applies to:

  • Microsoft Content Management Server 2001
  • NCompass Resolution 4.0

This article was previously published under Q302206

SUMMARY

This article provides comments on accessing the Microsoft Content Management Server Publishing API in Perl.

MORE INFORMATION

The main entry point for retrieving MSCMS Publishing API objects (such as postings and channels) is through the Autosession object. Autosession is the object in the Publishing API that relies on ASP. After Autosession has been initialized with the parameters of the HTTP request via ASP, the other objects can be retrieved and manipulated as required.

Any other entry point outside of ASP would have to find another way to specify the parameters normally transmitted through the ASP intrinsic objects (Server, Request, and so on); otherwise, it would have limited capabilities, such as only working in the default mode (Published). It would also not work in conjunction with the Autosession. The Publishing API is an apartment-threaded application, and ASP provides apartments for the Publishing API to run in. Any other calling environment should do the same; otherwise, threading issues would arise.

In theory, if the other language runs under ASP and supports COM, it should be able to use the Publishing API without any problems.

If you needed access outside of ASP, the script below will send information from a Content Management Server template to a Perl script. The Perl script writes the information to a text file, and then information will be sent back to MSCMS.

Example

MSCMS Template

Dim strVar
strVar = "Hello world"
Response.Redirect("http://server/PerlFile.pl" & "var=" & strVar)
				

Perl Code

#Collect variable from querystring
$temp=$ENV{'QUERY_STRING'};
@pairs=split(/&/,$temp);
foreach $item(@pairs) {
        ($key,$value)=split (/=/,$item,2);
        $value=~tr/+/ /;
        $value=~ s/%(..)/pack("c",hex($1))/ge;
        $fields{$key}=$value;
 
        #Check to see which variable we got back
        $var=$fields{'var'};
        }
#Create amd Open HTML file for writing
$htmlfile = "c:\" . "sample.html";
 
open (HTMLOUT, ">$htmlfile") || die "Sorry could not write to html out file";
 
#Output to HTML
print HTMLOUT "<HTML><BODY>" . $var . "</BODY></HTML>\n";
 

# Construct the querystring to send back to the MSCMS template
$query = "&perl=perl";
 
# Redirect back to the PerlBoard MSCMS template
print "Location: http://server/channels" . "?" . $query . "\n\n";
 
#EOF
				

Modification Type:MajorLast Reviewed:11/3/2003
Keywords:kbinfo KB302206