41 if ( !$stream_cutted or !class_exists(
"CDataXML"))
48 $stream = $stream_cutted;
52 if (!$xml->LoadString( $stream ))
54 $APPLICATION->ThrowException(
"Error: Can't parse request xml data. ");
58 $dom = $xml->GetTree();
59 $this->DOMDocument = $dom;
60 if ( get_class( $dom ) ==
"CDataXMLDocument" || get_class( $dom ) ==
"cdataxmldocument")
63 $response = $dom->elementsByName(
'Fault' );
68 $faultStringArray = $dom->elementsByName(
"faultstring" );
69 $this->FaultString = $faultStringArray[0]->textContent();
71 $faultCodeArray = $dom->elementsByName(
"faultcode" );
72 $this->FaultCode = $faultCodeArray[0]->textContent();
77 $body = $dom->elementsByName(
"Body" );
101 $responseAccessors =
$response->children();
103 if(
count($responseAccessors) > 0)
105 $this->Value =
array();
106 foreach($responseAccessors as $arChild)
108 $value = $arChild->decodeDataTypes();
109 $this->Value = array_merge($this->Value, $value);
115 $APPLICATION->ThrowException(
"Could not understand type of class decoded");
125 $APPLICATION->ThrowException(
"Could not process XML in response" );
132 global $xsd_simple_type;
133 $returnValue =
false;
135 $attr = $node->getAttribute(
"type");
136 if ($attr and mb_strlen($attr))
138 return new CSOAPFault(
"Server Error",
"Server supports only document/literal binding.");
142 if(trim($complexDataTypeName) <>
'')
144 $rootDataName = trim($complexDataTypeName);
147 if (!$rootDataName or !isset($this->typensVars[$rootDataName]))
149 return new CSOAPFault(
"Server Error",
"decodeDataTypes() can't find function type declaration." );
152 $name = $node->name();
153 $typeDeclaration =
array();
164 if (isset($this->typensVars[
$name]))
165 $typeDeclaration = $this->typensVars[
$name];
166 if (isset($this->typensVars[$rootDataName][
$name]))
167 $typeDeclaration = $this->typensVars[$rootDataName][
$name];
168 else if (isset($this->typensVars[$rootDataName][
"input"][
$name]))
169 $typeDeclaration = $this->typensVars[$rootDataName][
"input"][
$name];
170 else if (isset($this->typensVars[$rootDataName][
"output"][
$name]))
171 $typeDeclaration = $this->typensVars[$rootDataName][
"output"][
$name];
173 if (!
count($typeDeclaration))
175 return new CSOAPFault(
"Server Error",
"decodeDataTypes() can't find type declaration for {$name} param." );
179 if (isset($typeDeclaration[
"varType"]))
180 $dataType = $typeDeclaration[
"varType"];
185 if (isset($xsd_simple_type[$dataType]))
186 $dataType = $xsd_simple_type[$dataType];
191 $returnValue = strval($node->textContent());
195 $returnValue = intval($node->textContent());
200 $returnValue = ($node->textContent());
205 if ( $node->textContent() ==
"true" )
208 $returnValue =
false;
212 case "base64Binary" :
213 $returnValue = base64_decode($node->textContent());
218 $returnValue = $node;
223 if (isset($typeDeclaration[
"arrType"]))
228 $returnValue =
array();
230 $arrayType = $typeDeclaration[
"arrType"];
231 if (isset($typeDeclaration[
"maxOccursA"]))
232 $maxOccurs = $typeDeclaration[
"maxOccursA"];
234 if (isset($xsd_simple_type[$arrayType]))
237 $childs = $node->children();
238 foreach ($childs as $child)
241 $returnValue[] = $child->textContent();
242 if (intval($maxOccurs) and
$i>intval($maxOccurs))
248 foreach ($node->children() as $child)
255 if (!isset($this->typensVars[$child->name]))
256 $child->name = $arrayType;
259 if (is_object($decoded) and (get_class($decoded) ==
"CSOAPFault" or get_class($decoded) ==
"csoapfault"))
264 $returnValue[] = $decoded;
275 $returnValue =
array();
278 if (!isset($this->typensVars[$dataType]))
break;
279 $objectDecl = $this->typensVars[$dataType];
283 $serialize =
"assoc";
284 if (isset($objectDecl[
"serialize"]))
286 $serialize = $objectDecl[
"serialize"];
287 unset($objectDecl[
"serialize"]);
291 foreach ( $node->children() as $parameterNode )
293 if (!$parameterNode->name())
continue;
298 foreach($objectDecl as $pname => $param)
304 if (is_object($decoded) and (get_class($decoded) ==
"CSOAPFault" or get_class($decoded) ==
"csoapfault"))
309 if (!$decoded and (!isset($param[
"strict"]) or
310 (isset($param[
"strict"]) and $param[
"strict"] ==
"strict") ))
312 return new CSOAPFault(
"Server Error",
"Request has not enough params of strict type to be decoded. " );
318 if ($serialize ==
"class")
324 if (class_exists($dataType)) {
325 $objectClass =
new $dataType;
328 $existedVars = get_object_vars($objectClass);
329 foreach ($classRequest as $pname => $value)
331 if (!
is_set($existedVars, $pname))
333 $objectClass->$pname = $value;
342 if ($stillValid)
$params = $objectClass;
365 if (is_object($this->Value) && mb_strtoupper(get_class($this->Value)) ==
'CSOAPFAULT')
370 $faultCodeNode->setData($this->Value->faultCode());
372 $fault->addChild( $faultCodeNode );
374 $faultStringNode =
new CXMLCreator(
"faultstring" );
375 $faultStringNode->setData( $this->Value->faultString() );
377 $fault->addChild( $faultStringNode );
379 if ($this->Value->detail)
380 $fault->addChild($this->Value->detail());
382 $body->addChild( $fault );
387 $responseName = $this->Name .
"Response";
389 $response->setAttribute(
"xmlns", $this->Namespace);
390 if (!isset($this->typensVars[$this->Name][
"output"]) or !
count($this->typensVars[$this->Name][
"output"]))
392 if (
count($this->typensVars))
394 $GLOBALS[
'APPLICATION']->ThrowException(
"payload() can't find output type declaration.",
"SoapRespnose::payload()");
411 $valueEncoder->setTypensVars($this->typensVars);
413 foreach ($this->typensVars[$this->Name][
"output"] as $returnType => $returnParam)
417 $GLOBALS[
'APPLICATION']->ThrowException(
"payload() can't find output type declaration for {$this->Name}.",
"SoapRespnose::payload()");
421 $valueEncoder->setOutputVars($this->Name);
423 $value = $valueEncoder->encodeValue($returnType, isset($this->Value[$returnType]) ? $this->Value[$returnType] : $this->Value);
435 $root->addChild( $body );