function payload() { $root = new CXMLCreator("soap:Envelope"); $root->setAttribute("xmlns:soap", BX_SOAP_ENV); $root->setAttribute(BX_SOAP_XSI_PREFIX, BX_SOAP_SCHEMA_INSTANCE); $root->setAttribute(BX_SOAP_XSD_PREFIX, BX_SOAP_SCHEMA_DATA); $root->setAttribute(BX_SOAP_ENC_PREFIX, BX_SOAP_ENC); $header = new CXMLCreator("soap:Header"); $root->addChild($header); foreach ($this->Headers as $hx) { $header->addChild($hx); } // add the body $body = new CXMLCreator("soap:Body"); foreach ($this->BodyAttributes as $attribute => $value) { $body->setAttribute($attribute, $value); } // add the request $request = new CXMLCreator($this->Name); $request->setAttribute("xmlns", $this->Namespace); // add the request parameters $param = null; foreach ($this->Parameters as $parameter => $value) { unset($param); $param = CXMLCreator::encodeValueLight($parameter, $value); if ($param == false) { ShowError("Error enconding data for payload"); } $request->addChild($param); } $body->addChild($request); $root->addChild($body); return CXMLCreator::getXMLHeader() . $root->getXML(); }
function encodeValueLight($name, $value) { global $xsd_simple_type; //AddMessage2Log($name."|".mydump($value)); if (!$name) { ShowError("Tag name undefined (== 0) in encodeValueLight."); return false; } $node = CXMLCreator::createTagAttributed($name); $name = $node->tag; if (!$node) { ShowError("Can't create NODE object. Unable to parse tag name: " . $name); return false; } if (is_object($value) && strtolower(get_class($value)) == "cxmlcreator") { $node->addChild($value); } else { if (is_object($value)) { $ovars = get_object_vars($value); foreach ($ovars as $pn => $pv) { $decode = CXMLCreator::encodeValueLight($pn, $pv); if ($decode) { $node->addChild($decode); } } } else { if (is_array($value)) { foreach ($value as $pn => $pv) { $decode = CXMLCreator::encodeValueLight($pn, $pv); if ($decode) { $node->addChild($decode); } } } else { if (!$value) { $node->setData(""); } else { if (!isset($xsd_simple_type[gettype($value)])) { ShowError("Unknown param type."); return false; } } $node->setData($value); } } } return $node; }
function payload() { $root = new CXMLCreator("soap:Envelope"); $root->setAttribute("xmlns:soap", BX_SOAP_ENV); // add the body $body = new CXMLCreator("soap:Body"); // Check if it's a fault if (is_object($this->Value) && ToUpper(get_class($this->Value)) == 'CSOAPFAULT') { $fault = new CXMLCreator("soap:Fault"); $faultCodeNode = new CXMLCreator("faultcode"); $faultCodeNode->setData($this->Value->faultCode()); $fault->addChild($faultCodeNode); $faultStringNode = new CXMLCreator("faultstring"); $faultStringNode->setData($this->Value->faultString()); $fault->addChild($faultStringNode); if ($this->Value->detail) { $fault->addChild($this->Value->detail()); } $body->addChild($fault); } else { // add the request $responseName = $this->Name . "Response"; $response = new CXMLCreator($responseName); $response->setAttribute("xmlns", $this->Namespace); if (!isset($this->typensVars[$this->Name]["output"]) or !count($this->typensVars[$this->Name]["output"])) { if (count($this->typensVars)) { $GLOBALS['APPLICATION']->ThrowException("payload() can't find output type declaration.", "SoapRespnose::payload()"); return; } else { //print_r($this->Value); //die(); // EncodeLight $value = CXMLCreator::encodeValueLight($this->ValueName, $this->Value); } $response->addChild($value); } else { //$return = new CXMLCreator($returnType); $valueEncoder = new CSOAPCodec(); $valueEncoder->setTypensVars($this->typensVars); foreach ($this->typensVars[$this->Name]["output"] as $returnType => $returnParam) { if (!$returnType) { $GLOBALS['APPLICATION']->ThrowException("payload() can't find output type declaration for {$this->Name}.", "SoapRespnose::payload()"); return; } $valueEncoder->setOutputVars($this->Name); $value = $valueEncoder->encodeValue($returnType, isset($this->Value[$returnType]) ? $this->Value[$returnType] : $this->Value); $response->addChild($value); } //AddM } $body->addChild($response); } $root->addChild($body); //AddMessage2Log($root->getXML()); return CXMLCreator::getXMLHeader() . $root->getXML(); }
$value = htmlspecialcharsEx($_POST[$pname]); } echo " \n\t\t\t<tr>\n\t\t\t\t<td class=\"frmText\" style=\"color: #000000; font-weight: normal;\">{$pname}:</td>\n\t\t\t\t<td><input value=\"{$value}\" class=\"frmInput\" type=\"text\" size=\"50\" name=\"{$pname}\"></td>\n\t\t\t</tr>\n\t\t\t"; } echo "\n\t\t<tr>\n\t\t\t<td></td>\n\t\t\t<td align=\"right\"><input type=\"submit\" value=\"" . GetMessage("BX_WSTMPL_ERROR_SUBMIT") . "\" class=\"button\"></td>\n\t\t</tr>\n\t\t"; echo "</table></form>"; if (isset($_GET["directcall"]) and count($request) < count($input)) { $request = array(); echo GetMessage("BX_WSTMPL_ERROR_NOTENOUGHTPARAMS"); } if (isset($_GET["directcall"])) { echo "<b>" . GetMessage("BX_WSTMPL_RESULT") . "</b><br>"; if (count($request) == count($input) and class_exists($getclass)) { $object = new $getclass(); $result = call_user_func_array(array($object, $getop), $request); $xml = CXMLCreator::encodeValueLight("result", $result); $xml_str = $xml->getXML(); global $APPLICATION; $APPLICATION->RestartBuffer(); $payload = CXMLCreator::getXMLHeader() . $xml_str; header("Pragma: no-cache"); header("SOAPServer: BITRIX SOAP"); header("Content-Type: text/xml; charset=\"UTF-8\""); Header("Content-Length: " . (defined('BX_UTF') && BX_UTF == 1 && function_exists('mb_strlen') ? mb_strlen($payload, 'latin1') : strlen($payload))); echo $payload; die; } else { echo GetMessage("BX_WSTMPL_ERROR_UNKNOWN"); } } ?>