function payload()
 {
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->name = "eZSOAP message";
     $root = $doc->createElementNS(eZSOAPEnvelope::ENV, eZSOAPEnvelope::ENV_PREFIX . ':Envelope');
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSI_PREFIX, eZSOAPEnvelope::SCHEMA_INSTANCE);
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSD_PREFIX, eZSOAPEnvelope::SCHEMA_DATA);
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::ENC_PREFIX, eZSOAPEnvelope::ENC);
     // add the body
     $body = $doc->createElement(eZSOAPEnvelope::ENV_PREFIX . ':Body');
     $root->appendChild($body);
     // Check if it's a fault
     if ($this->Value instanceof eZSOAPFault) {
         $fault = $doc->createElement(eZSOAPEnvelope::ENV_PREFIX . ':Fault');
         $faultCodeNode = $doc->createElement("faultcode", $this->Value->faultCode());
         $fault->appendChild($faultCodeNode);
         $faultStringNode = $doc->createElement("faultstring", $this->Value->faultString());
         $fault->appendChild($faultStringNode);
         $body->appendChild($fault);
     } else {
         // add the request
         $responseName = $this->Name . "Response";
         if ($this->Namespace == '') {
             $response = $doc->createElement("resp:" . $responseName);
         } else {
             $response = $doc->createElementNS($this->Namespace, "resp:" . $responseName);
         }
         $return = $doc->createElement("return");
         $value = eZSOAPCodec::encodeValue($doc, "return", $this->Value);
         $body->appendChild($response);
         $response->appendChild($value);
     }
     $doc->appendChild($root);
     return $doc->saveXML();
 }
 static function encodeValue($doc, $name, $value)
 {
     switch (gettype($value)) {
         case "string":
             $node = $doc->createElement($name);
             $node->appendChild($doc->createTextNode($value));
             $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::XSD_PREFIX . ':string');
             return $node;
             break;
         case "boolean":
             $node = $doc->createElement($name);
             $node->appendChild($doc->createTextNode($value ? 'true' : 'false'));
             $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::XSD_PREFIX . ':boolean');
             return $node;
             break;
         case "integer":
             $node = $doc->createElement($name);
             $node->appendChild($doc->createTextNode($value));
             $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::XSD_PREFIX . ':int');
             return $node;
             break;
         case "double":
             $node = $doc->createElement($name);
             $node->appendChild($doc->createTextNode($value));
             $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::XSD_PREFIX . ':float');
             return $node;
             break;
         case "array":
             $arrayCount = count($value);
             $isStruct = false;
             // Check for struct
             $i = 0;
             foreach ($value as $key => $val) {
                 if ($i !== $key) {
                     $isStruct = true;
                     break;
                 }
                 $i++;
             }
             if ($isStruct == true) {
                 $node = $doc->createElement($name);
                 $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::ENC_PREFIX . ':SOAPStruct');
                 foreach ($value as $key => $val) {
                     $subNode = eZSOAPCodec::encodeValue($doc, (string) $key, $val);
                     $node->appendChild($subNode);
                 }
                 return $node;
             } else {
                 $node = $doc->createElement($name);
                 $node->setAttribute(eZSOAPEnvelope::XSI_PREFIX . ':type', eZSOAPEnvelope::ENC_PREFIX . ':Array');
                 $node->setAttribute(eZSOAPEnvelope::ENC_PREFIX . ':arrayType', eZSOAPEnvelope::XSD_PREFIX . ":string[{$arrayCount}]");
                 foreach ($value as $arrayItem) {
                     $subNode = eZSOAPCodec::encodeValue($doc, "item", $arrayItem);
                     $node->appendChild($subNode);
                 }
                 return $node;
             }
             break;
     }
     return false;
 }
 function payload()
 {
     $doc = new DOMDocument("1.0");
     $doc->name = 'eZSOAP message';
     $root = $doc->createElementNS(eZSOAPEnvelope::ENV, eZSOAPEnvelope::ENV_PREFIX . ':Envelope');
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSI_PREFIX, eZSOAPEnvelope::SCHEMA_INSTANCE);
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSD_PREFIX, eZSOAPEnvelope::SCHEMA_DATA);
     $root->setAttribute('xmlns:' . eZSOAPEnvelope::ENC_PREFIX, eZSOAPEnvelope::ENC);
     // add the body
     $body = $doc->createElement(eZSOAPEnvelope::ENV_PREFIX . ':Body');
     $body->setAttribute('xmlns:req', $this->Namespace);
     foreach ($this->BodyAttributes as $name => $value) {
         $body->setAttribute($name, $value);
     }
     $root->appendChild($body);
     // add the request
     $request = $doc->createElement('req:' . $this->Name);
     // add the request parameters
     foreach ($this->Parameters as $parameter) {
         $param = eZSOAPCodec::encodeValue($doc, $parameter->name(), $parameter->value());
         if ($param == false) {
             eZDebug::writeError("Error encoding data for payload: " . $parameter->name(), __METHOD__);
             continue;
         }
         $request->appendChild($param);
     }
     $body->appendChild($request);
     $doc->appendChild($root);
     return $doc->saveXML();
 }