Ejemplo n.º 1
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();
 }
Ejemplo 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();
 }