[Stack-cvs] stack-1-0/scripts/rqp RQPv1p0Server.php,1.2.2.1,1.2.2.2 nb_soapfuncs.php,1.2.2.1,1.2.2.2
From: pkiddie <pk...@us...> - 2005-08-29 21:51:31
|
Update of /cvsroot/stack/stack-1-0/scripts/rqp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18141/scripts/rqp Modified Files: Tag: development_rqp RQPv1p0Server.php nb_soapfuncs.php Log Message: New version of SOAP functions to return SOAP errors where necessary Index: RQPv1p0Server.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/RQPv1p0Server.php,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** RQPv1p0Server.php 26 Aug 2005 17:36:50 -0000 1.2.2.1 --- RQPv1p0Server.php 29 Aug 2005 21:51:21 -0000 1.2.2.2 *************** *** 60,63 **** --- 60,65 ---- $stack_ver['cvsmodule'] = 'stack-1-0'; + $stack_web_services_provide = TRUE; + // "Insert *s where needed"; $stackOptions['InsertStars']['type'] = 'list'; *************** *** 209,213 **** { include("../../stackstd.php"); //Reqd for version info for STACK ! global $stack_ver, $stack_web_url; // return new nbSOAPFault("unimplemented", "The RQP_ServerInformationservice has not been implemented yet", ""); $si['type'] = "STACK"; --- 211,220 ---- { include("../../stackstd.php"); //Reqd for version info for STACK ! global $stack_ver, $stack_web_url, $stack_web_services_provide; ! ! if (!$stack_web_services_provide) { ! return new nbSOAPFault("notImplemented", "The RQP_ServerInformation service is not available on this server"); ! } ! // return new nbSOAPFault("unimplemented", "The RQP_ServerInformationservice has not been implemented yet", ""); $si['type'] = "STACK"; *************** *** 239,242 **** --- 246,254 ---- function RQP_ItemInformation($source) { + global $stack_web_services_provide; + + if (!$stack_web_services_provide) { + return new nbSOAPFault("notImplemented", "The RQP_ItemInformation service is not available on this server"); + } //First we check to see if the source intantiates a valid question, if so set isValid to true *************** *** 315,319 **** */ function RQP_Render($source, $options, &$persistentData, $inputData, $directives, $mimetypes, $namePrefix, $itemBase, $resourceBase, $tempfileBase) ! { require("../../stackstd.php"); //Reqd for version info for STACK //require("../moodlelib.php"); --- 327,337 ---- */ function RQP_Render($source, $options, &$persistentData, $inputData, $directives, $mimetypes, $namePrefix, $itemBase, $resourceBase, $tempfileBase) ! { ! global $stack_web_services_provide; ! ! if (!$stack_web_services_provide) { ! return new nbSOAPFault("notImplemented", "The RQP_ServerInformation service is not available on this server"); ! } ! require("../../stackstd.php"); //Reqd for version info for STACK //require("../moodlelib.php"); Index: nb_soapfuncs.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/nb_soapfuncs.php,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** nb_soapfuncs.php 26 Aug 2005 17:36:50 -0000 1.2.2.1 --- nb_soapfuncs.php 29 Aug 2005 21:51:21 -0000 1.2.2.2 *************** *** 65,71 **** $startTime = time(); $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, $timeLimit); stream_set_timeout($sock, 2); stream_set_blocking($sock, false); ! echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging if($sock == false) --- 65,77 ---- $startTime = time(); $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, $timeLimit); + if($sock==FALSE) + { + $fault = new nbSOAPFault("Server", "Timed out trying to contact server.", "No response from server."); + $fault = "<soap:Body>\n" . $fault->soapify() . "</soap:Body>\n"; + return nbSOAP_Envelope($fault); + } stream_set_timeout($sock, 2); stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging if($sock == false) *************** *** 85,98 **** $cl = strlen($contents); $contents .= fread($sock, 8192); ! /* if(!$headersComplete) { ! $headerEnd = strpos($contents,"\r\n\r\n"); ! if($headerEnd != false) { ! $headersComplete = true; ! $clp = strpos($contents,"Content-Length:"); ! $cle = strpos($contents,"\r\n",$clp); ! $contentLength = intval(trim(substr($contents, $clp+15, $cle-$clp-15))); ! $headerLength = $cle+4; } } --- 91,123 ---- $cl = strlen($contents); $contents .= fread($sock, 8192); ! if(!$headersComplete) { ! //# remove any leading continues ! $headerEnd = strpos($contents,"\r\n\r\n"); ! while(($headerEnd != false)&&(!$headersComplete)) { ! $fle = strpos($contents,"\r\n"); // first line end ! $line = substr($contents, 0, $fle); ! list($protocol, $rcode) = split(" ", $line, 3); ! $rcode = intval($rcode); // ensure its an integer; ! if(($rcode >= 100)&&($rcode <= 199)) // informational, I'm not interested ! { ! $contents = substr($contents, $headerEnd+4); ! $headerEnd = strpos($contents,"\r\n\r\n"); ! } ! elseif($rcode == 200) ! { ! $headersComplete = true; ! $clp = strpos($contents,"Content-Length:"); ! $cle = strpos($contents,"\r\n",$clp); ! $contentLength = intval(trim(substr($contents, $clp+15, $cle-$clp-15))); ! $headerLength = $cle+4; ! } ! else ! { ! $fault = new nbSOAPFault("Server", "An http error was returned, http code $rcode", "An http error was returned, http code $rcode"); ! $fault = "<soap:Body>\n" . $fault->soapify() . "</soap:Body>\n"; ! return nbSOAP_Envelope($fault); ! } } } *************** *** 101,113 **** if(strlen($contents)>=$contentLength+$headerLength) $pageComplete = true; ! } */ $callTime = time()-$startTime; if($callTime >= $timeLimit) $pageComplete = true; ! echo "<p><i><pre>[" . htmlentities($contents) . "]</pre></i></p>"; } fclose($sock); } ! echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging return $contents; } --- 126,143 ---- if(strlen($contents)>=$contentLength+$headerLength) $pageComplete = true; ! } $callTime = time()-$startTime; if($callTime >= $timeLimit) + { $pageComplete = true; ! $fault = new nbSOAPFault("Server", "Timed out calling server.", "No response, or an incomplete response before the request timed out."); ! $fault = "<soap:Body>\n" . $fault->soapify() . "</soap:Body>\n"; ! return nbSOAP_Envelope($fault); ! } ! //echo "<p><i><pre>[" . htmlentities($contents) . "]</pre></i></p>"; } fclose($sock); } ! //echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging return $contents; } |