I have a web service that I need to use to fill <select> boxes in a form. I am trying to do this via the FormAPI, and have hit a snag. I am filling one select box when the user chooses an option in a previous select box. So i attached an event listener to the first select, to be fired "onItemChange." In that event handler, I have this code:
function handleItemChange() {
IWDatacapture.displayMessage("Retrieving...");
top.hiddenFrameRunning = true;
IWDatacapture.callServer('http://my-ts-server.mydomain.com/iw-bin/my-cgi.ipl', {'web_service_url': 'http://webservice.domain.com'});
}
This calls my cgi script, which looks like this:
#!C:\Interwoven\Teamsite/iw-perl/bin/iwperl -w
use CGI;
use HTTP::Request;
use LWP::UserAgent;
$| = 1;
my $in = new CGI;
my $url = $in->param('web_service_url');
my $ua = LWP::UserAgent->new;
$ua->agent('Teamsite/1');
my $req = HTTP::Request->new(GET => $url);
$req->content_type('text/html');
my $res = $ua->request($req);
if ($res->is_success) {
print $res->content;
} else {
print <
<script language="javascript">
var choices = {'extrainfo': '', 'choices': []};
</script>
EOT
}
exit;
The webservice returns html & javascript like this:
[html]
<script language="javascript">
var choices = {
'choices': [],
'extrainfo': ''
};
choices.choices[0] = new Option('value', 'key', false, false);
choices.choices[1] = new Option('value2', 'key2', false, false);
</script>
[/html]
I have confirmed that it is making the HTTP request correctly, and is recieving the correct response. I have run the CGI script from the command line, using iwperl and replacing the CGI module code with appropriate substitutions, and gotten the correct response, so I know iwperl supports the LWP and HTTP modules. When I replace the CGI script with a script that does not make the HTTP request, and just returns the html/javascript right from the cgi script, it works fine, so I know my `populateDropDown()` function is working correctly. When I use the CGI script with the HTTP request in it, the hidden frame isn't even loaded into the form, which doesn't make much sense to me, since no matter what the http request returns, there is valid html/javascript being return by the CGI script.
I tried calling the web service right from IWDatacapture.callServer(), and recieved a response, but (i think) due to the fact that the web service is at a different subdomain from Teamsite, the form was unable to use the returned html/javascript. When i tried it, i got a message about the respones not having permission to access `parent.getScriptFrame()`.
If anyone can enlighten me on this, I'd appreciate it.