Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Remote server calls
tsrookie
Gidday All,
I understand from a previous post thatthis is the best solution for callServer from formapi
'> Browsers aren't real keen on Javascript being written to them from an
> "unknown" server...so, you can't really do a callServer to a server
> other than the TeamSite server (where the whole page is coming from).'
Can someone suggest the best location to place the script that I call from the remote server call
we are running
Thanks
Colin
ts 6.1 sp2 on solaris
Find more posts tagged with
Comments
Adam Stoller
IWHOME/httpd/iw-bin is the best place to locate scripts used for callServer() as I recall - they can be referenced with the URI "/iw-bin/scriptname.cgi"
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
chuckles
If you
really
want to do a remote server call, you can always call a script on your server that does and LWP call on the sly to another server and just regurgitates the response.
gzevin
well,. I told this to tsrookie in a private conversation, but he does not seem to trust me on this...
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
tsrookie
Thank you all for your help,
I found an interesting tech article as well for anyone interested.
https://support.interwoven.com/kb/kb_show_article2.asp?ArticleID=49824
this is what the formapi doumentation on the server doesn't tell you
regards
Colin
tsrookie
Hi all,
More questions
I have now written a cgi that parses my xml doc to retrieve values for the drop down boxes, the formapi documentation says that you have to return a chunk of valid HTML. I just don't know how to return it. Do you simply print it to the screen?
The script is designed to return the business units that make up a division or the sub-business units that make up a business unit.
I pass 3 parameters to it.
lookingFor (either business-unit or sub-business-unit)
selected (the value of the selected option)
the id of the divison or business unit
#!/web/Interwoven/TeamSite/iw-perl/bin/iwperl
#
use XML::XPath;
use egov:
ebugLog;
my $DEBUG = 1;
my $debug = new egov:
ebugLog ($DEBUG, "/tmp/orgstructureparser.cgi.log");
my %parameter;
if (length ($ENV{'QUERY_STRING'}) > 0){
my $buffer = $ENV{'QUERY_STRING'};
$debug->printlog("buffer: $buffer");
my
@pairs
= split(/&/, $buffer);
foreach my $pair (
@pairs){
my ($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$parameter{$name} = $value;
$debug->printlog($name . '=>' . $value);
}
}
my $query;
my $id = $parameter{id};
my $lookingFor = $parameter{lookingFor};
my $selected = (( $parameter{selected} ne '' ) ? $parameter{selected} : '' );
if( $lookingFor eq 'business-unit' ){
# $query = q{//division[
@id=
'} . $id .q{']/business-unit/
@name|//division[
@id=
'} . $id . q{']/business-unit/
@id}
;
$query = q{//division[
@id=
'} . $id .q{']/business-unit/
@name}
;
$debug->printlog("query: $query");
}
elsif( $lookingFor eq 'sub-business-unit' ){
# $query = q{//division/business-unit[
@id=
'}. $id . q{']/sub-business-unit/
@name|//division/business-unit[
@id=
'} . $id . q{']/sub-business-unit/
@id}
;
$query = q{//division/business-unit[
@id=
'}. $id . q{']/sub-business-unit/
@name}
;
$debug->printlog("query: $query");
}
my $fileToParse = qq[/web/Interwoven/TeamSite/custom/config/DET_structure.xml];
# my $query = q|//business-unit[
@id=
'221']/
@name|
;
# my $query = q[//division[
@id=
'221']/business-unit/
@name|//division[
@id=
'221']/business-unit/
@id]
;
# my $query = q[//division/business-unit[
@id=
'300']/sub-business-unit/
@name|//division/business-unit[
@id=
'300']/sub-business-unit/
@id]
;
my $xp = XML::XPath->new( filename => "$fileToParse" );
my $node_set1 = $xp->find( $query );
my $outHTML;
$outHTML = <<"EOS";
<html>
<head>
<script language="javascript">
// Get handle to the FormAPI/userscript frame.
api = parent.getScriptFrame();
// newOptions = new Array();
var selected = '$selected';
var isSelected = false;
topics = new Array();
EOS
my $buName;
my $buId;
my $count = 0;
foreach my $nodeA ( $node_set1->get_nodelist ) {
$buName = $nodeA->getNodeValue;
$debug->printlog("buName: $buName");
if( $lookingFor eq 'business-unit' ){
$query = q{//division[
@id=
'}. $id . q{']/business-unit[
@name=
'} . $buName . q{']/
@id}
;
$debug->printlog("query: $query");
}elsif( $lookingFor eq 'sub-business-unit' ){
$query = q{//division/business-unit[
@id=
'}. $id . q{']/sub-business-unit[
@name=
'} . $buName . q{']/
@id}
;
$debug->printlog("query: $query");
}
my $node_set2 = $xp->find( $query );
foreach my $nodeB ( $node_set2->get_nodelist ) {
$buId = $nodeB->getNodeValue;
$debug->printlog("buId: $buId");
}
my $selected = $parameter{selected};
$outHTML .= 'topics[' . $count . ']="' . $buId . '=>' . $buName .'"' . ";\n";
$count++;
}
$outHTML .= <<EOS;
for( i = 0; i < topics.length; i++ ){
var keyValuePair = topics
;
var splitArray=keyValuePair.split("=>");
var theKey = splitArray[0];
var theValue = splitArray[1];
if( theValue == '' ){ theValue = theKey; }
isSelected = false;
if( theValue == selected ){ isSelected = true; }
newOptions
= new Option( theValue, theKey, isSelected, isSelected );
}
api.IWDatacapture.getItem("/businessUnit").setOptions(newOptions);
</script>
</head>
<body>
</body>
</html>
EOS
$debug->printlog("--------------------------------");
$debug->printlog($outHTML);
print $outHTML;
A sample of the data I am parsing is below.
<?xml version="1.0" encoding="UTF-8" ?>
<organisation lastUpdate="21/03/05">
<division name="Office of the Director-General" id="202">
<business-unit name="Correspondence unit" id="203" />
</division>
<division name="Office of the Deputy Director-General" id="276" />
<division name="Strategic Communications and Marketing" id="204">
<business-unit name="Communications unit" id="1002" />
</division>
<division name="Strategic Legal Unit" id="1003" />
<division name="Internal Audit" id="222" />
<division name="Strategic Infrastructure Initiatives" id="1022" />
<division name="Human Resource Strategy and Performance" id="221">
<business-unit name="Workforce Capability" id="214" />
<business-unit name="Ethics" id="214C" />
<business-unit name="eDRMS Project" id="1024" />
<business-unit name="Workforce Management" id="216" />
<business-unit name="Strategic Legal and FOI" id="1003" />
<business-unit name="HR Strategy and Information Policy and Reporting - name may change" id="221">
<sub-business-unit name="HR Business/Workforce Planning" id="1024" />
<sub-business-unit name="HR Strategy" id="1025" />
<sub-business-unit name="HR Governance/Governance Structures" id="1026" />
<sub-business-unit name="HR Reporting" id="1027" />
<sub-business-unit name="HR Business Performance and Analysis" id="1028" />
<sub-business-unit name="HR Information System Protocols" id="1029" />
</business-unit>
<business-unit name="Office of the GM (HR)" id="1005" />
</division>
<division name="Office of the Apprenticeship and Traineeship Ombudsman" id="297" />
<division name="Office of Chief Information Officer" id="275A" />
<division name="Employment and Indigenous Initiatives" id="298">
</organisation>