function processRequest()
 {
     global $HTTP_SERVER_VARS;
     if ($_SERVER["REQUEST_METHOD"] != "POST") {
         print "Error: this web page does only understand POST methods";
         exit;
     }
     $xmlData = $this->stripHTTPHeader($this->RawPostData);
     $dom = new DOMDocument('1.0', 'utf-8');
     $dom->preserveWhiteSpace = false;
     $success = $dom->loadXML($xmlData);
     // Check for non-parsing XML, to avoid call to non-object error.
     if (!$success) {
         $this->showResponse('unknown_function_name', 'unknown_namespace_uri', new eZSOAPFault('Server Error', 'Bad XML'));
         return;
     }
     // add namespace fetching on body
     // get the SOAP body
     $body = $dom->getElementsByTagName("Body");
     $children = $body->item(0)->childNodes;
     if ($children->length == 1) {
         $requestNode = $children->item(0);
         // get target namespace for request
         $functionName = $requestNode->localName;
         $namespaceURI = $requestNode->namespaceURI;
         $params = array();
         // check parameters
         foreach ($requestNode->childNodes as $parameterNode) {
             $params[] = eZSOAPResponse::decodeDataTypes($parameterNode);
         }
         list($objectName, $objectFunctionName) = preg_split('/::/', $functionName, 2, PREG_SPLIT_NO_EMPTY);
         if (!$objectFunctionName and in_array($functionName, $this->FunctionList) && function_exists($functionName)) {
             $this->showResponse($functionName, $namespaceURI, call_user_func_array($functionName, $params));
         } else {
             if ($objectName and $objectFunctionName) {
                 if (!class_exists($objectName)) {
                     $this->showResponse($functionName, $namespaceURI, new eZSOAPFault('Server Error', 'Object not found'));
                 } else {
                     $object = new $objectName();
                     if (!method_exists($object, $objectFunctionName)) {
                         $this->showResponse($functionName, $namespaceURI, new eZSOAPFault('Server Error', 'Objectmethod not found'));
                     } else {
                         $this->showResponse($functionName, $namespaceURI, call_user_func_array(array($object, $objectFunctionName), $params));
                     }
                 }
             } else {
                 $this->showResponse($functionName, $namespaceURI, new eZSOAPFault('Server Error', 'Method not found'));
             }
         }
     } else {
         // error
         $this->showResponse($functionName, $namespaceURI, new eZSOAPFault('Server Error', '"Body" element in the request ' . 'has wrong number of children'));
     }
 }
示例#2
0
 static function decodeDataTypes($node, $type = "")
 {
     $returnValue = false;
     $attributeValue = '';
     $attribute = $node->getAttributeNodeNS(eZSOAPEnvelope::SCHEMA_INSTANCE, 'type');
     if (!$attribute) {
         $attribute = $node->getAttributeNodeNS('http://www.w3.org/1999/XMLSchema-instance', 'type');
     }
     $attributeValue = $attribute->value;
     $dataType = $type;
     $attrParts = explode(":", $attributeValue);
     if ($attrParts[1]) {
         $dataType = $attrParts[1];
     }
     /*
             $typeNamespacePrefix = $this->DOMDocument->namespaceByAlias( $attrParts[0] );
     
             check that this is a namespace type definition
                     if ( ( $typeNamespacePrefix == eZSOAPEnvelope::SCHEMA_DATA ) ||
                          ( $typeNamespacePrefix == eZSOAPEnvelope::ENC )
                          )
     TODO: add encoding checks with schema validation.
     */
     switch ($dataType) {
         case "string":
         case "int":
         case "float":
         case 'double':
             $returnValue = $node->textContent;
             break;
         case "boolean":
             if ($node->textContent == "true") {
                 $returnValue = true;
             } else {
                 $returnValue = false;
             }
             break;
         case "base64":
             $returnValue = base64_decode($node->textContent);
             break;
         case "Array":
             // Get array type
             $arrayType = $node->getAttributeNodeNS(eZSOAPEnvelope::ENC, 'arrayType')->value;
             $arrayTypeParts = explode(":", $arrayType);
             preg_match("#(.*)\\[(.*)\\]#", $arrayTypeParts[1], $matches);
             $type = $matches[1];
             $count = $matches[2];
             $returnValue = array();
             foreach ($node->childNodes as $child) {
                 if ($child instanceof DOMElement) {
                     $returnValue[] = eZSOAPResponse::decodeDataTypes($child, $type);
                 }
             }
             break;
         case "SOAPStruct":
             $returnValue = array();
             foreach ($node->childNodes as $child) {
                 if ($child instanceof DOMElement) {
                     $returnValue[$child->tagName] = eZSOAPResponse::decodeDataTypes($child);
                 }
             }
             break;
         default:
             foreach ($node->childNodes as $childNode) {
                 if ($childNode instanceof DOMElement) {
                     // check data type for child
                     $attr = $childNode->getAttributeNodeNS(eZSOAPEnvelope::SCHEMA_INSTANCE, 'type')->value;
                     $dataType = false;
                     $attrParts = explode(":", $attr);
                     $dataType = $attrParts[1];
                     $returnValue[$childNode->tagName] = eZSOAPResponse::decodeDataTypes($childNode);
                 }
             }
             break;
     }
     return $returnValue;
 }