Esempio n. 1
0
 function ShowRawResponse($valueEncoded, $wrapEnvelope = false)
 {
     global $APPLICATION;
     if ($wrapEnvelope) {
         // $valueEncoded class of CXMLCreator
         $root = new CXMLCreator("soap:Envelope");
         $root->setAttribute("xmlns:soap", BX_SOAP_ENV);
         // add the body
         $body = new CXMLCreator("soap:Body");
         $body->addChild($valueEncoded);
         $root->addChild($body);
         $valueEncoded = $root;
     }
     $payload = CXMLCreator::getXMLHeader() . $valueEncoded->getXML();
     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)));
     $APPLICATION->RestartBuffer();
     $this->RawPayloadData = $payload;
     echo $payload;
 }
Esempio n. 2
0
 public 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();
 }
Esempio n. 3
0
 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();
 }
Esempio n. 4
0
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");
    }
}
?>

</div>

</body>