- Модуль: webservice
- Путь к файлу: ~/bitrix/modules/webservice/classes/general/soap/soapresponse.php
- Класс: forCSOAPResponse
- Вызов: CSOAPResponse::decodeStream
function decodeStream( $request, $stream )
{
global $APPLICATION;
$stream_cutted = $this->stripHTTPHeader( $stream );
if ( !$stream_cutted or !class_exists("CDataXML"))
{
$APPLICATION->ThrowException("Error: BitrixXMLParser. "
."Downloaded page:
". htmlspecialcharsEx($stream));
return;
}
$stream = $stream_cutted;
$xml = new CDataXML();
$stream = $APPLICATION->ConvertCharset($stream, "UTF-8", SITE_CHARSET);
if (!$xml->LoadString( $stream ))
{
$APPLICATION->ThrowException( "Error: Can't parse request xml data. ");
return;
}
$dom = $xml->GetTree();
$this->DOMDocument = $dom;
if ( get_class( $dom ) == "CDataXMLDocument" || get_class( $dom ) == "cdataxmldocument")
{
// check for fault
$response = $dom->elementsByName( 'Fault' );
if ( count( $response ) == 1 )
{
$this->IsFault = 1;
$faultStringArray = $dom->elementsByName( "faultstring" );
$this->FaultString = $faultStringArray[0]->textContent();
$faultCodeArray = $dom->elementsByName( "faultcode" );
$this->FaultCode = $faultCodeArray[0]->textContent();
return;
}
// get the response
$body = $dom->elementsByName( "Body" );
$body = $body[0];
if($body)
{
$response = $body->children();
$response = $response[0];
if(get_class($response) == "CDataXMLNode" || get_class($response) == "cdataxmlnode")
{
/*Cut from the SOAP spec:
The method response is viewed as a single struct containing an accessor
for the return value and each [out] or [in/out] parameter.
The first accessor is the return value followed by the parameters
in the same order as in the method signature.
Each parameter accessor has a name corresponding to the name
of the parameter and type corresponding to the type of the parameter.
The name of the return value accessor is not significant.
Likewise, the name of the struct is not significant.
However, a convention is to name it after the method name
with the string "Response" appended.
*/
$responseAccessors = $response->children();
//echo ''; print_r($responseAccessors); echo '
';
if(count($responseAccessors) > 0)
{
$this->Value = array();
foreach($responseAccessors as $arChild)
{
$value = $arChild->decodeDataTypes();
$this->Value = array_merge($this->Value, $value);
}
}
}
else
{
$APPLICATION->ThrowException("Could not understand type of class decoded");
}
}
else
{
$APPLICATION->ThrowException("Wrong XML in response");
}
}
else
{
$APPLICATION->ThrowException( "Could not process XML in response" );
}
}