From: pkiddie <pk...@us...> - 2005-07-28 15:04:12
|
Update of /cvsroot/stack/stack-1-0/scripts/rqp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7780/scripts/rqp Modified Files: Tag: development_xmlrqp RQPv1p0Server.php index.php nb_easyxml_lite.php nb_soapfuncs.php Added Files: Tag: development_xmlrqp RQPv1p0Client.php Log Message: Added a changelog with history of changes, Nialls latest RQP code, and some changes to integrate this RQP code --- NEW FILE: RQPv1p0Client.php --- <?php include("nb_easyxml_lite.php"); include("nb_soapfuncs.php"); /********* Data structures used by this web service ********* * * type ServerInformationDType{ * ['name']=>string * ['version']=>string * ['rqpVersion']=>string * ['studentDocs']=>anyURI * ['teacherDocs']=>anyURI * ['adminDocs']=>anyURI * ['operations']=>array(string, ...) * ['serverProperties']=>array({ * ['key']=>string * ['val']=>string * }, ...) * ['mimetypes']=>array(string, ...) * ['resources']=>array(anyURI, ...) * } * * type ItemInformationDType{ * ['name']=>string * ['itemProperties']=>array({ * ['key']=>string * ['val']=>string * }, ...) * ['error']=>string * ['warning']=>string * } * * type RenderDType{ * ['persistentData']=>string * ['outcomeVars']=>array({ * ['key']=>string * ['val']=>string * }, ...) * ['onSubmit']=>string * ['head']=>array(string, ...) * ['output']=>array({ * ['key']=>string * ['val']=>string * }, ...) * ['mimetype']=>string * ['files']=>array(anyURI, ...) * } * * type kvPair{ * ['key']=>string * ['val']=>string * } * * type input{ * ['key']=>string * ['val']=>string * } * * type CloneDType{ * ['clones']=>array(string, ...) * } * */ class RQPv1p0 { var $Url; /** * web service consumer method RQP_ServerInformation * * @return ServerInformationDType */ function RQP_ServerInformation() // returns a ServerInformationDType { $soapXML = "<soap:Body>\n"; $soapXML .= "<RQP_ServerInformation xmlns=\"http://mantis.york.ac.uk/rqp_v1p0\">\n"; $soapXML .= "</RQP_ServerInformation>\n"; $soapXML .= "</soap:Body>\n"; $soapXML = nbSOAP_Envelope($soapXML); // Send the request (syncronous http 1.0 only at the moment) $soapOut = nbSOAP_request10($this->Url, "http://mantis.york.ac.uk/rqp_v1p0/RQP_ServerInformation", $soapXML); // is it an error? $soapStart = strpos($soapOut, "<?xml"); if($soapStart==-1) return false; $xml = nb_easyxmldoc(substr($soapOut,$soapStart)); $body = $xml->findElement("Body", 0, "http://schemas.xmlsoap.org/soap/envelope/"); $cp = $xml->FindChildElement($body); if($cp==false) // empty soap:Body return null; $tn = $xml->getName($cp); if($tn=="Fault") // should really report it... return desoap_nbSOAPFault($xml, $cp); if($tn != "RQP_ServerInformationResponse") return null; $cp = $xml->FindChildElement($cp); if($cp==false) // empty value return null; $result = $this->desoap_ServerInformationDType($xml, $cp, "RQP_ServerInformation"); return $result; } /** * web service consumer method RQP_ItemInformation * * @param source : string * @return ItemInformationDType */ function RQP_ItemInformation($source) // returns a ItemInformationDType { $soapXML = "<soap:Body>\n"; $soapXML .= "<RQP_ItemInformation xmlns=\"http://mantis.york.ac.uk/rqp_v1p0\">\n"; // Parameter string source $soapXML .= $this->soapify_string($source, "source"); $soapXML .= "</RQP_ItemInformation>\n"; $soapXML .= "</soap:Body>\n"; $soapXML = nbSOAP_Envelope($soapXML); // Send the request (syncronous http 1.0 only at the moment) $soapOut = nbSOAP_request10($this->Url, "http://mantis.york.ac.uk/rqp_v1p0/RQP_ItemInformation", $soapXML); // is it an error? $soapStart = strpos($soapOut, "<?xml"); if($soapStart==-1) return false; $xml = nb_easyxmldoc(substr($soapOut,$soapStart)); $body = $xml->findElement("Body", 0, "http://schemas.xmlsoap.org/soap/envelope/"); $cp = $xml->FindChildElement($body); if($cp==false) // empty soap:Body return null; $tn = $xml->getName($cp); if($tn=="Fault") // should really report it... return desoap_nbSOAPFault($xml, $cp); if($tn != "RQP_ItemInformationResponse") return null; $cp = $xml->FindChildElement($cp); if($cp==false) // empty value return null; $result = $this->desoap_ItemInformationDType($xml, $cp, "RQP_ItemInformation"); return $result; } /** * web service consumer method RQP_Render * * @param source : string * @param options : kvPair[] * @param persistentData : string * @param inputData : input[] * @param directives : string[] * @param mimetypes : string[] * @param namePrefix : QName * @param itemBase : anyURI * @param resourceBase : anyURI * @param tempfileBase : anyURI * @return RenderDType */ function RQP_Render($source, $options, $persistentData, $inputData, $directives, $mimetypes, $namePrefix, $itemBase, $resourceBase, $tempfileBase) // returns a RenderDType { $soapXML = "<soap:Body>\n"; $soapXML .= "<RQP_Render xmlns=\"http://mantis.york.ac.uk/rqp_v1p0\">\n"; // Parameter string source $soapXML .= $this->soapify_string($source, "source"); // Parameter kvPair[] options $soapXML .= $this->soapify_kvPairArray($options, "options"); // Parameter string persistentData $soapXML .= $this->soapify_string($persistentData, "persistentData"); // Parameter input[] inputData $soapXML .= $this->soapify_inputArray($inputData, "inputData"); // Parameter string[] directives $soapXML .= $this->soapify_stringArray($directives, "directives"); // Parameter string[] mimetypes $soapXML .= $this->soapify_stringArray($mimetypes, "mimetypes"); // Parameter QName namePrefix $soapXML .= $this->soapify_QName($namePrefix, "namePrefix"); // Parameter anyURI itemBase $soapXML .= $this->soapify_anyURI($itemBase, "itemBase"); // Parameter anyURI resourceBase $soapXML .= $this->soapify_anyURI($resourceBase, "resourceBase"); // Parameter anyURI tempfileBase $soapXML .= $this->soapify_anyURI($tempfileBase, "tempfileBase"); $soapXML .= "</RQP_Render>\n"; $soapXML .= "</soap:Body>\n"; $soapXML = nbSOAP_Envelope($soapXML); // Send the request (syncronous http 1.0 only at the moment) $soapOut = nbSOAP_request10($this->Url, "http://mantis.york.ac.uk/rqp_v1p0/RQP_Render", $soapXML); // is it an error? $soapStart = strpos($soapOut, "<?xml"); if($soapStart==-1) return false; $xml = nb_easyxmldoc(substr($soapOut,$soapStart)); $body = $xml->findElement("Body", 0, "http://schemas.xmlsoap.org/soap/envelope/"); $cp = $xml->FindChildElement($body); if($cp==false) // empty soap:Body return null; $tn = $xml->getName($cp); if($tn=="Fault") // should really report it... return desoap_nbSOAPFault($xml, $cp); if($tn != "RQP_RenderResponse") return null; $cp = $xml->FindChildElement($cp); if($cp==false) // empty value return null; $result = $this->desoap_RenderDType($xml, $cp, "RQP_Render"); return $result; } /** * web service consumer method RQP_Clone * * @param source : string * @param number : int * @return CloneDType */ function RQP_Clone($source, $number) // returns a CloneDType { $soapXML = "<soap:Body>\n"; $soapXML .= "<RQP_Clone xmlns=\"http://mantis.york.ac.uk/rqp_v1p0\">\n"; // Parameter string source $soapXML .= $this->soapify_string($source, "source"); // Parameter int number $soapXML .= $this->soapify_int($number, "number"); $soapXML .= "</RQP_Clone>\n"; $soapXML .= "</soap:Body>\n"; $soapXML = nbSOAP_Envelope($soapXML); // Send the request (syncronous http 1.0 only at the moment) $soapOut = nbSOAP_request10($this->Url, "http://mantis.york.ac.uk/rqp_v1p0/RQP_Clone", $soapXML); // is it an error? $soapStart = strpos($soapOut, "<?xml"); if($soapStart==-1) return false; $xml = nb_easyxmldoc(substr($soapOut,$soapStart)); $body = $xml->findElement("Body", 0, "http://schemas.xmlsoap.org/soap/envelope/"); $cp = $xml->FindChildElement($body); if($cp==false) // empty soap:Body return null; $tn = $xml->getName($cp); if($tn=="Fault") // should really report it... return desoap_nbSOAPFault($xml, $cp); if($tn != "RQP_CloneResponse") return null; $cp = $xml->FindChildElement($cp); if($cp==false) // empty value return null; $result = $this->desoap_CloneDType($xml, $cp, "RQP_Clone"); return $result; } function soapify_ServerInformationDType($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('name', $input)) $ret .= $this->soapify_string($input['name'], "name"); if(array_key_exists('version', $input)) $ret .= $this->soapify_string($input['version'], "version"); if(array_key_exists('rqpVersion', $input)) $ret .= $this->soapify_string($input['rqpVersion'], "rqpVersion"); if(array_key_exists('studentDocs', $input)) $ret .= $this->soapify_anyURI($input['studentDocs'], "studentDocs"); if(array_key_exists('teacherDocs', $input)) $ret .= $this->soapify_anyURI($input['teacherDocs'], "teacherDocs"); if(array_key_exists('adminDocs', $input)) $ret .= $this->soapify_anyURI($input['adminDocs'], "adminDocs"); if(array_key_exists('operations', $input)) $ret .= $this->soapify_stringArray($input['operations'], "operations"); if(array_key_exists('serverProperties', $input)) $ret .= $this->soapify_kvPairArray($input['serverProperties'], "serverProperties"); if(array_key_exists('mimetypes', $input)) $ret .= $this->soapify_stringArray($input['mimetypes'], "mimetypes"); if(array_key_exists('resources', $input)) $ret .= $this->soapify_anyURIArray($input['resources'], "resources"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_ServerInformationDType($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string name case "name": $ret['name'] = $xml->getContent($cidx); break; // string version case "version": $ret['version'] = $xml->getContent($cidx); break; // string rqpVersion case "rqpVersion": $ret['rqpVersion'] = $xml->getContent($cidx); break; // anyURI studentDocs case "studentDocs": $ret['studentDocs'] = $xml->getContent($cidx); break; // anyURI teacherDocs case "teacherDocs": $ret['teacherDocs'] = $xml->getContent($cidx); break; // anyURI adminDocs case "adminDocs": $ret['adminDocs'] = $xml->getContent($cidx); break; // string[] operations case "operations": $ret['operations'] = $this->desoap_stringArray($xml, $cidx, "operations"); break; // kvPair[] serverProperties case "serverProperties": $ret['serverProperties'] = $this->desoap_kvPairArray($xml, $cidx, "serverProperties"); break; // string[] mimetypes case "mimetypes": $ret['mimetypes'] = $this->desoap_stringArray($xml, $cidx, "mimetypes"); break; // anyURI[] resources case "resources": $ret['resources'] = $this->desoap_anyURIArray($xml, $cidx, "resources"); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_ItemInformationDType($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('name', $input)) $ret .= $this->soapify_string($input['name'], "name"); if(array_key_exists('itemProperties', $input)) $ret .= $this->soapify_kvPairArray($input['itemProperties'], "itemProperties"); if(array_key_exists('error', $input)) $ret .= $this->soapify_string($input['error'], "error"); if(array_key_exists('warning', $input)) $ret .= $this->soapify_string($input['warning'], "warning"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_ItemInformationDType($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string name case "name": $ret['name'] = $xml->getContent($cidx); break; // kvPair[] itemProperties case "itemProperties": $ret['itemProperties'] = $this->desoap_kvPairArray($xml, $cidx, "itemProperties"); break; // string error case "error": $ret['error'] = $xml->getContent($cidx); break; // string warning case "warning": $ret['warning'] = $xml->getContent($cidx); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_string($input, $name) { $ret = "<$name>"; $ret .= encodeXMLSafeString($input); $ret .= "</$name>\n"; return $ret; } function desoap_string($xml, $idx, $name) { // ideally I should check element name is $name first $ret = decodeXMLSafeString($xml->getContent($idx)); return $ret; } function soapify_RenderDType($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('persistentData', $input)) $ret .= $this->soapify_string($input['persistentData'], "persistentData"); if(array_key_exists('outcomeVars', $input)) $ret .= $this->soapify_kvPairArray($input['outcomeVars'], "outcomeVars"); if(array_key_exists('onSubmit', $input)) $ret .= $this->soapify_string($input['onSubmit'], "onSubmit"); if(array_key_exists('head', $input)) $ret .= $this->soapify_stringArray($input['head'], "head"); if(array_key_exists('output', $input)) $ret .= $this->soapify_kvPairArray($input['output'], "output"); if(array_key_exists('mimetype', $input)) $ret .= $this->soapify_string($input['mimetype'], "mimetype"); if(array_key_exists('files', $input)) $ret .= $this->soapify_anyURIArray($input['files'], "files"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_RenderDType($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string persistentData case "persistentData": $ret['persistentData'] = $xml->getContent($cidx); break; // kvPair[] outcomeVars case "outcomeVars": $ret['outcomeVars'] = $this->desoap_kvPairArray($xml, $cidx, "outcomeVars"); break; // string onSubmit case "onSubmit": $ret['onSubmit'] = $xml->getContent($cidx); break; // string[] head case "head": $ret['head'] = $this->desoap_stringArray($xml, $cidx, "head"); break; // kvPair[] output case "output": $ret['output'] = $this->desoap_kvPairArray($xml, $cidx, "output"); break; // string mimetype case "mimetype": $ret['mimetype'] = $xml->getContent($cidx); break; // anyURI[] files case "files": $ret['files'] = $this->desoap_anyURIArray($xml, $cidx, "files"); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_kvPair($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('key', $input)) $ret .= $this->soapify_string($input['key'], "key"); if(array_key_exists('val', $input)) $ret .= $this->soapify_string($input['val'], "val"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_kvPair($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string key case "key": $ret['key'] = $xml->getContent($cidx); break; // string val case "val": $ret['val'] = $xml->getContent($cidx); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_input($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('key', $input)) $ret .= $this->soapify_string($input['key'], "key"); if(array_key_exists('val', $input)) $ret .= $this->soapify_string($input['val'], "val"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_input($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string key case "key": $ret['key'] = $xml->getContent($cidx); break; // string val case "val": $ret['val'] = $xml->getContent($cidx); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_QName($input, $name) { $ret = "<$name>"; $ret .= encodeXMLSafeString($input); $ret .= "</$name>\n"; return $ret; } function desoap_QName($xml, $idx, $name) { // ideally I should check element name is $name first $ret = decodeXMLSafeString($xml->getContent($idx)); return $ret; } function soapify_anyURI($input, $name) { $ret = "<$name>"; $ret .= encodeXMLSafeString($input); $ret .= "</$name>\n"; return $ret; } function desoap_anyURI($xml, $idx, $name) { // ideally I should check element name is $name first $ret = decodeXMLSafeString($xml->getContent($idx)); return $ret; } function soapify_CloneDType($input, $name) { $ret = "<$name>"; $ret .= "\n"; if(array_key_exists('clones', $input)) $ret .= $this->soapify_stringArray($input['clones'], "clones"); $ret .= "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_CloneDType($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $nm = $xml->getName($cidx); switch($nm) { // string[] clones case "clones": $ret['clones'] = $this->desoap_stringArray($xml, $cidx, "clones"); break; } $cidx = $xml->FindNextPeer($cidx); } return $ret; } function soapify_int($input, $name) { $ret = "<$name>"; $ret .= strval(intval($input)); $ret .= "</$name>\n"; return $ret; } function desoap_int($xml, $idx, $name) { // ideally I should check element name is $name first $ret = decodeXMLSafeString($xml->getContent($idx)); return $ret; } function soapify_kvPairArray($input, $name) { $ret = "<$name>\n"; if(is_array($input)) { reset($input); while(list($k, $v)=each($input)) { $ret .= $this->soapify_kvPair($v, "kvPair") . "\n"; } } else $ret .= $this->soapify_kvPair($input, "kvPair") . "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_kvPairArray($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $ret[] = $this->desoap_kvPair($xml, $cidx, "kvPair"); $cidx = $xml->FindNextPeer($cidx); } } function soapify_inputArray($input, $name) { $ret = "<$name>\n"; if(is_array($input)) { reset($input); while(list($k, $v)=each($input)) { $ret .= $this->soapify_input($v, "input") . "\n"; } } else $ret .= $this->soapify_input($input, "input") . "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_inputArray($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $ret[] = $this->desoap_input($xml, $cidx, "input"); $cidx = $xml->FindNextPeer($cidx); } } function soapify_stringArray($input, $name) { $ret = "<$name>\n"; if(is_array($input)) { reset($input); while(list($k, $v)=each($input)) { $ret .= $this->soapify_string($v, "string") . "\n"; } } else $ret .= $this->soapify_string($input, "string") . "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_stringArray($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $ret[] = $this->desoap_string($xml, $cidx, "string"); $cidx = $xml->FindNextPeer($cidx); } } function soapify_anyURIArray($input, $name) { $ret = "<$name>\n"; if(is_array($input)) { reset($input); while(list($k, $v)=each($input)) { $ret .= $this->soapify_anyURI($v, "anyURI") . "\n"; } } else $ret .= $this->soapify_anyURI($input, "anyURI") . "\n"; $ret .= "</$name>\n"; return $ret; } function desoap_anyURIArray($xml, $idx, $name) { $ret = array(); $cidx = $xml->FindChildElement($idx); while($cidx != false) { $ret[] = $this->desoap_anyURI($xml, $cidx, "anyURI"); $cidx = $xml->FindNextPeer($cidx); } } } ?> Index: RQPv1p0Server.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/Attic/RQPv1p0Server.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** RQPv1p0Server.php 28 Jul 2005 13:38:01 -0000 1.1.2.1 --- RQPv1p0Server.php 28 Jul 2005 15:03:48 -0000 1.1.2.2 *************** *** 1,1213 **** ! <?php ! include("nb_easyxml_lite.php"); ! include("nb_soapfuncs.php"); ! include("rqp_util.php"); //Stack/RQP utility functions ! ! /********* Data structures used by this web service ********* ! * ! * type ServerInformationDType{ ! * ['identifier']=>anyURI ! * ['name']=>string [...2421 lines suppressed...] ! } ! else ! $ret .= $this->soapify_anyURI($input, "anyURI") . "\n"; ! $ret .= "</$name>\n"; ! return $ret; ! } ! ! function desoap_anyURIArray($xml, $idx, $name) ! { ! $ret = array(); ! $cidx = $xml->FindChildElement($idx); ! while($cidx != false) ! { ! $ret[] = $this->desoap_anyURI($xml, $cidx, "anyURI"); ! } ! } ! ! } ! ?> ! Index: nb_soapfuncs.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/Attic/nb_soapfuncs.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** nb_soapfuncs.php 28 Jul 2005 13:38:01 -0000 1.1.2.1 --- nb_soapfuncs.php 28 Jul 2005 15:03:48 -0000 1.1.2.2 *************** *** 1,108 **** ! <?php ! /***************************************************************************** ! The purpose of this library is to provide a very simple, interoperable ! SOAP implentation for PHP that is not dependent on any optional libraries and ! can function with both PHP version 4.3 and PHP version 5. ! This library is expected to be used with generated code from ws_gen and ! requires nb_easyxml.php. ! *****************************************************************************/ ! ! class nbSOAP ! { ! //# this is just a placeholder for now, eventually it will ! // hold serialization methods for inbuilt types and ! // the SOAP request functions. ! } ! ! // HTTP 1.1 version; under development, not ready for use ! function nbSOAP_request11($URI, $SOAPAction, $data) ! { ! $contents = ""; ! $urldata = parse_url($URI); ! if(!array_key_exists('port', $urldata)) ! $urldata['port']=80; ! $request = "POST " . $urldata['path'] . " HTTP/1.1\r\n"; ! $request .= "Host: ". $urldata['host'] ."\r\n"; ! $request .= "Accept: */*\r\n"; ! $request .= "User-Agent: PHP-script\r\n"; ! $request .= "Content-Type: text/xml; charset=utf-8\r\n"; ! $request .= "Content-length: " . strlen($data) . "\r\n"; ! $request .= "SOAPAction: \"" . $SOAPAction . "\"\r\n\r\n"; ! $request .= $data; ! $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, 30); ! stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; //## ! ! if($sock == false) ! { ! return false; ! } ! else ! { ! fputs($sock, $request); ! //# this part needs to properly check the length of response, and ! //# time out neatly if there's too long a delay. ! $cl = strlen($contents); ! $contents .= fread($sock, 8192); ! while ((!feof($sock))&&($cl < strlen($contents))) ! { ! $cl = strlen($contents); ! $contents .= fread($sock, 8192); ! } ! fclose($sock); ! } ! echo "<pre>" . htmlentities($contents) . "</pre>"; ! return $contents; ! ! } ! ! function nbSOAP_request10($URI, $SOAPAction, $data) ! { ! $contents = ""; ! $urldata = parse_url($URI); ! if(!array_key_exists('port', $urldata)) ! $urldata['port']=80; ! $request = "POST " . $urldata['path'] . " HTTP/1.0\r\n"; ! $request .= "Host: ". $urldata['host'] ."\r\n"; ! $request .= "Accept: */*\r\n"; ! $request .= "User-Agent: PHP-script\r\n"; ! $request .= "Content-Type: text/xml; charset=utf-8\r\n"; ! $request .= "Content-length: " . strlen($data) . "\r\n"; ! $request .= "SOAPAction: \"" . $SOAPAction . "\"\r\n\r\n"; ! $request .= $data; ! $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, 30); ! stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging ! ! if($sock == false) ! { ! return false; ! } ! else ! { ! fputs($sock, $request); ! while (!feof($sock)) ! { ! $contents .= fread($sock, 8192); ! } ! fclose($sock); ! } ! //echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging ! return $contents; ! ! } ! ! function nbSOAP_Envelope($body) ! { ! $body = trim($body); ! if(substr($body,0,10) != "<soap:Body") ! return false; ! $soapXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ! $soapXML .= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; ! $soapXML .= "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"; ! $soapXML .= $body; ! $soapXML .= "\n</soap:Envelope>\n"; ! return $soapXML; ! } ! ?> \ No newline at end of file --- 1,156 ---- ! <?php ! /***************************************************************************** ! The purpose of this library is to provide a very simple, interoperable ! SOAP implentation for PHP that is not dependent on any optional libraries and ! can function with both PHP version 4.3 and PHP version 5. ! This library is expected to be used with generated code from ws_gen and ! requires nb_easyxml.php. ! *****************************************************************************/ ! ! class nbSOAPFault ! { ! var $faultcode; ! var $faultstring; ! var $faultdetail; ! ! function nbSOAPFault($faultcode, $faultstring, $faultdetail) ! { ! $this->faultcode = $faultcode; ! $this->faultstring = $faultstring; ! $this->faultdetail = $faultdetail; ! $this->faultactor = $_SERVER['PHP_SELF']; ! } ! ! function soapify() ! { ! $out = "<soap:Fault>\n"; ! $out .= "<faultcode>".$this->faultcode."</faultcode>\n"; ! $out .= "<faultstring>".$this->faultstring."</faultstring>\n"; ! $out .= "<faultactor>".$this->faultactor."</faultactor>\n"; ! $out .= "<faultdetail>".$this->faultdetail."</faultdetail>\n"; ! $out .= "</soap:Fault>"; ! return $out; ! } ! } ! ! function desoap_nbSOAPFault($xmp, $cp) ! { ! return new nbSOAPFault("","",""); ! } ! ! ! class nbSOAP ! { ! //# this is just a placeholder for now, eventually it will ! // hold serialization methods for inbuilt types and ! // the SOAP request functions. ! } ! ! // HTTP 1.1 version; under development, not ready for use ! function nbSOAP_request11($URI, $SOAPAction, $data) ! { ! $contents = ""; ! $urldata = parse_url($URI); ! if(!array_key_exists('port', $urldata)) ! $urldata['port']=80; ! $request = "POST " . $urldata['path'] . " HTTP/1.1\r\n"; ! $request .= "Host: ". $urldata['host'] ."\r\n"; ! $request .= "Accept: */*\r\n"; ! $request .= "User-Agent: PHP-script\r\n"; ! $request .= "Content-Type: text/xml; charset=utf-8\r\n"; ! $request .= "Content-length: " . strlen($data) . "\r\n"; ! $request .= "SOAPAction: \"" . $SOAPAction . "\"\r\n\r\n"; ! $request .= $data; ! $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, 30); ! stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; //## ! ! if($sock == false) ! { ! return false; ! } ! else ! { ! fputs($sock, $request); ! //# this part needs to properly check the length of response, and ! //# time out neatly if there's too long a delay. ! $cl = strlen($contents); ! $contents .= fread($sock, 8192); ! while ((!feof($sock))&&($cl < strlen($contents))) ! { ! $cl = strlen($contents); ! $contents .= fread($sock, 8192); ! } ! fclose($sock); ! } ! echo "<pre>" . htmlentities($contents) . "</pre>"; ! return $contents; ! ! } ! ! function nbSOAP_request10($URI, $SOAPAction, $data) ! { ! $contents = ""; ! $urldata = parse_url($URI); ! if(!array_key_exists('port', $urldata)) ! $urldata['port']=80; ! $request = "POST " . $urldata['path'] . " HTTP/1.0\r\n"; ! $request .= "Host: ". $urldata['host'] ."\r\n"; ! $request .= "Accept: */*\r\n"; ! $request .= "User-Agent: PHP-script\r\n"; ! $request .= "Content-Type: text/xml; charset=utf-8\r\n"; ! $request .= "Content-length: " . strlen($data) . "\r\n"; ! $request .= "SOAPAction: \"" . $SOAPAction . "\"\r\n\r\n"; ! $request .= $data; ! $sock = fsockopen($urldata['host'],$urldata['port'], $errno, $errmsg, 30); ! stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging ! ! if($sock == false) ! { ! return false; ! } ! else ! { ! fputs($sock, $request); ! while (!feof($sock)) ! { ! $contents .= fread($sock, 8192); ! } ! fclose($sock); ! } ! //echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging ! return $contents; ! ! } ! ! function nbSOAP_Envelope($body) ! { ! $body = trim($body); ! if(substr($body,0,10) != "<soap:Body") ! return false; ! $soapXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ! $soapXML .= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; ! $soapXML .= "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"; ! $soapXML .= $body; ! $soapXML .= "\n</soap:Envelope>\n"; ! return $soapXML; ! } ! ! function encodeXMLSafeString($in) ! { ! // this is virtually the same as htmlspecialchars, however I've made my own version to ! // ensure it always matches the decodeXMLSafeString function. ! $plain = array("&", "<", ">", "\""); ! $code = array("&", "<", ">", """); ! return str_replace($plain, $code, strval($in)); ! } ! ! function decodeXMLSafeString($in) ! { ! $code = array("<", ">", """, "&"); ! $plain = array("<", ">", "\"", "&"); ! return str_replace($code, $plain, $in); ! } ! ?> \ No newline at end of file Index: nb_easyxml_lite.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/Attic/nb_easyxml_lite.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** nb_easyxml_lite.php 28 Jul 2005 13:38:01 -0000 1.1.2.1 --- nb_easyxml_lite.php 28 Jul 2005 15:03:48 -0000 1.1.2.2 *************** *** 1,524 **** ! <?PHP ! ! /*!< This set of classes and function is to provide a simple method of ! * dealing with XML that does not depend on optional libraries ! */ ! ! define("START_TAG",1); ! define("END_TAG",2); ! define("CLOSED_TAG",3); ! define("CONTENT",4); [...1021 lines suppressed...] ! ! function getAttribute($index, $attribname) ! { ! if((is_array($this->entities[$index]->attribs))&&(array_key_exists($attribname,$this->entities[$index]->attribs))) ! return $this->entities[$index]->attribs[$attribname]; ! else ! return ""; ! } ! ! }; ! ! function nb_easyxmldoc($inp) ! { ! $dom = new nb_easyxml; ! $dom->parsein($inp); ! return $dom; ! } ! ?> \ No newline at end of file Index: index.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/Attic/index.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** index.php 28 Jul 2005 13:38:01 -0000 1.1.2.1 --- index.php 28 Jul 2005 15:03:48 -0000 1.1.2.2 *************** *** 1,16 **** ! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ! <html><head><title>RQP 1.0 test</title></head> ! ! <body> ! ! <?php ! include("RQPv1p0Client.php"); ! ! $rqpserver = new RQPv1p0(); ! $rqpserver->Url = "http://localhost/RQPv1p0/RQPv1p0Server.php"; ! $serverInfo = $rqpserver->RQP_ServerInformation(); ! echo serialize($serverInfo); ! ! ?> ! </body> </html> \ No newline at end of file --- 1,16 ---- ! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ! <html><head><title>RQP 1.0 test</title></head> ! ! <body> ! ! <?php ! include("RQPv1p0Client.php"); ! ! $rqpserver = new RQPv1p0(); ! $rqpserver->Url = "http://localhost/RQPv1p0/RQPv1p0Server.php"; ! $serverInfo = $rqpserver->RQP_ServerInformation(); ! echo serialize($serverInfo); ! ! ?> ! </body> </html> \ No newline at end of file |