@@ -23,7 +23,7 @@ WebworkClient.pm
2323
2424=head1 SYNPOSIS
2525 our $xmlrpc_client = new WebworkClient (
26- url => $XML_URL,
26+ url => $ce->{server_site_url},
2727 form_action_url => $FORM_ACTION_URL,
2828 site_password => $XML_PASSWORD//'',
2929 courseID => $credentials{courseID},
@@ -62,9 +62,11 @@ use warnings;
6262
6363# To configure the target webwork server
6464# two URLs are required
65- # 1. $XML_URL http://test.webwork.maa.org/mod_xmlrpc
65+ # 1. $SITE_URL http://test.webwork.maa.org/mod_xmlrpc
6666# points to the Webservice.pm and Webservice/RenderProblem modules
6767# Is used by the client to send the original XML request to the webservice
68+ # Note: This is not the same as the webworkClient->url which should NOT have
69+ # the mod_xmlrpc segment.
6870#
6971# 2. $FORM_ACTION_URL http:http://test.webwork.maa.org/webwork2/html2xml
7072# points to the renderViaXMLRPC.pm module.
@@ -87,10 +89,11 @@ use warnings;
8789# The renderViaXMLRPC.pm translates the WeBWorK form, has it processes by the webservice
8890# and returns the result to the browser.
8991# The The client renderProblem.pl script is no longer involved.
90- # 4. Summary: renderProblem.pl is only involved in the first round trip
91- # of the submitted problem. After that the communication is between the browser and
92- # renderViaXMLRPC using HTML forms and between renderViaXMLRPC and the WebworkWebservice.pm
93- # module using XML_RPC.
92+ # 4. Summary: The WebworkWebservice (with command renderProblem) is called directly in the first round trip
93+ # of submitting the problem via the https://mysite.edu/mod_xmlrpc route. After that the communication is
94+ # between the browser and renderViaXMLRPC using HTML forms and the route https://mysite.edu/webwork2/html2xml
95+ # and from there renderViaXMLRPC calls the WebworkWebservice using the route https://mysite.edu/mod_xmlrpc with the
96+ # renderProblem command.
9497
9598
9699our @COMMANDS = qw( listLibraries renderProblem ) ; # listLib readFile tex2pdf
@@ -264,23 +267,33 @@ sub xmlrpcCall {
264267
265268 my $requestResult ;
266269 my $transporter = TRANSPORT_METHOD-> new;
267-
270+ # FIXME -- transitional error fix to remove mod_xmlrpc from end of url call
271+ my $site_url = $self -> site_url;
272+ if ($site_url =~ / mod_xmlrpc$ / ){
273+ $site_url =~ s | /mod_xmlrpc/?|| ; # mod_xmlrpc from https://my.site.edu/mod_xmlrpc
274+ $self -> site_url($site_url );
275+ # complain
276+ print STDERR " \n\n\$ self->site_url() should not end in /mod_xmlrpc \n\n " ;
277+ }
268278 eval {
269279 $requestResult = $transporter
270280 # ->uri('http://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_CLASS)
271281 # -> proxy(PROTOCOL.'://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_URI);
272- -> proxy(($self -> url ).' /' .REQUEST_URI);
282+ -> proxy(($site_url ).' /' .REQUEST_URI);
273283 };
274- print STDERR " WebworkClient: Initiating xmlrpc request to url " ,($self -> url).' /' .REQUEST_URI, " \n Error: $@ \n " if $@ ;
284+ # END of FIXME section
285+
286+ print STDERR " WebworkClient: Initiating xmlrpc request to url " ,($self -> site_url).' /' .REQUEST_URI, " \n Error: $@ \n " if $@ ;
275287 # turn off verification of the ssl cert
276288 $transporter -> transport-> ssl_opts(verify_hostname => 0,
277289 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE);
278290
279291 if ($UNIT_TESTS_ON ) {
280- print STDERR " WebworkClient.pm " .__LINE__ ." xmlrpcCall sent to " , $self -> url," \n " ;
281- print STDERR " WebworkClient.pm " .__LINE__ ." xmlrpcCall issued with command $command \n " ;
282- print STDERR " WebworkClient.pm " .__LINE__ ." input is: " ,join (" " , %{$self -> request_object})," \n " ;
283- print STDERR " WebworkClient.pm " .__LINE__ ." xmlrpcCall $command initiated webwork webservice object $requestResult \n " ;
292+ print STDERR " \n\t WebworkClient.pm " .__LINE__ ." xmlrpcCall sent to site " , $self -> site_url," \n " ;
293+ print STDERR " \t WebworkClient.pm " .__LINE__ ." full xmlrpcCall path " , ($self -> site_url).' /' .REQUEST_URI," \n " ;
294+ print STDERR " \t WebworkClient.pm " .__LINE__ ." xmlrpcCall issued with command $command \n " ;
295+ print STDERR " \t WebworkClient.pm " .__LINE__ ." input is: " ,join (" " , map {$_ //' --' } %{$self -> request_object})," \n " ;
296+ print STDERR " \t WebworkClient.pm " .__LINE__ ." xmlrpcCall $command initiated webwork webservice object $requestResult \n " ;
284297 }
285298
286299 local ( $result );
@@ -353,7 +366,7 @@ sub jsXmlrpcCall {
353366 my $transporter = TRANSPORT_METHOD-> new;
354367
355368 my $requestResult = $transporter
356- -> proxy(($self -> url ).' /' .REQUEST_URI);
369+ -> proxy(($self -> site_url ).' /' .REQUEST_URI);
357370 $transporter -> transport-> ssl_opts(verify_hostname => 0,
358371 SSL_verify_mode => ' SSL_VERIFY_NONE' );
359372
@@ -382,28 +395,26 @@ sub jsXmlrpcCall {
382395 }
383396}
384397
385- =head2 encodeSource
386398
387399
388- =cut
389- sub encodeSource {
390- my $self = shift ;
391- my $source = shift ||' ' ;
392- $self -> {encoded_source } =encode_utf8_base64($source );
393- }
394-
395400=head2 Accessor methods
396-
401+ enconcodeSource # encode source string with utf8 and base64 and store in encoded_source
397402 encoded_source
398403 request_object
399404 return_object
400405 error_string
401406 fault
402- url
407+ site_url (https://mysite.edu)
403408 form_data
404409
405410=cut
406411
412+ sub encodeSource {
413+ my $self = shift ;
414+ my $source = shift ||' ' ;
415+ $self -> {encoded_source } =encode_utf8_base64($source );
416+ }
417+
407418sub encoded_source {
408419 my $self = shift ;
409420 my $source = shift ;
@@ -434,9 +445,17 @@ sub fault {
434445 $self -> {fault_flag } =$fault_flag if defined $fault_flag and $fault_flag =~/ \S / ; # source is non-empty
435446 $self -> {fault_flag };
436447}
437- sub url {
448+ sub site_url { # site_url https://mysite.edu
449+ my $self = shift ;
450+ my $new_url = shift ;
451+ $self -> {site_url } = $new_url if defined ($new_url ) and $new_url =~ / \S / ;
452+ $self -> {site_url };
453+ }
454+
455+ sub url { # site_url https://mysite.edu
438456 my $self = shift ;
439457 my $new_url = shift ;
458+ die " use webworkClient->site_url instead of webworkClient->url" ;
440459 $self -> {url } = $new_url if defined ($new_url ) and $new_url =~ / \S / ;
441460 $self -> {url };
442461}
0 commit comments