Skip to content

Commit 8bc8145

Browse files
committed
Discover the server_root_url from the configuration file instead of setting it manually in WSDL.pm
1 parent b57a123 commit 8bc8145

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/WebworkSOAP/WSDL.pm

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,31 @@ use Pod::WSDL;
55
use WebworkSOAP;
66

77
use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 );
8-
use constant RPC_URL => 'http://localhost/webwork2_rpc';
8+
9+
BEGIN {
10+
###############################################################################
11+
# Configuration -- set to top webwork directory (webwork2) (set in webwork.apache2-config)
12+
# Configuration -- set server url automatically for this file
13+
###############################################################################
14+
15+
our $webwork_directory = $WeBWorK::Constants::WEBWORK_DIRECTORY; #'/opt/webwork/webwork2';
16+
print "WebworkSOAP::WSDL: webwork_directory set to ", $WeBWorK::Constants::WEBWORK_DIRECTORY,
17+
" via \$WeBWorK::Constants::WEBWORK_DIRECTORY set in webwork.apache2-config\n";
18+
my $seed_ce = new WeBWorK::CourseEnvironment({ webwork_dir => $webwork_directory });
19+
die "Can't create seed course environment for webwork in $webwork_directory" unless ref($seed_ce);
20+
my $server_root_url = $seed_ce->{server_root_url}; #"http://localhost";
21+
our $RPC_URL = "$server_root_url/webwork2_rpc";
22+
print "WebworkSOAP::WSDL: rpc_url set to $RPC_URL \n";
23+
24+
}
25+
26+
927

1028
sub handler($) {
1129
my ($r) = @_;
1230
my $pod = new Pod::WSDL(
1331
source => 'WebworkSOAP',
14-
location => RPC_URL,
32+
location => $RPC_URL,
1533
pretty => 1,
1634
withDocumentation => 0
1735
);

lib/WebworkWebservice.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/user/bin/perl -w
22

3-
3+
# initialize SOAP interface as well
4+
use WebworkSOAP;
5+
use WebworkSOAP::WSDL;
46

57
BEGIN {
68
$main::VERSION = "2.4.9";

0 commit comments

Comments
 (0)