Documentation

CXMLCreator

CXMLCreator is a class that represents an XML document tag containing attributes, child elements, text data and CDATA.

Methods

Method Description
CXMLCreator(
 string tag,
 boolean cdata
)
Standard constructor. Takes the name of the tag as an input parameter.
static
CXMLCreator
createTagAttributed(
 string heavyTag
)
Creates a new tag (CXMLCreator) based on the tag name heavyTag in a special format.
static
CXMLCreator
encodeValueLight(
 string name,
 AnyType Value
)
Creates an XML tree of a document with the name Name and a structure Value.
Name is the tag name in the heavyTag format of createTagAttributed.
Value can be any data type, e.g. nested associated arrays

See the example below.
setCDATA Sets the tag CDATA contents.
setAttribute Sets the tag attribute.
setData Sets the tag text.
setName Sets the tag name.
addChild Adds an element to a list of child items.
getChildrenCount Returns the number of children elements.
getXML Returns an XML document as a string.
getXMLHeader Returns the header of an XML document.

Using SOAP server requests in a SOAP handler



class CMSSOAPResearch extends CSOAPServerResponser
{
    ...

    function ProcessRequestBody(&$cserver, $body) 
    {
        $functionName = $body->name();
        $namespaceURI = $body->namespaceURI();
        $requestNode = $body;
        
        if ($functionName == "Registration")
        {
            $root = new CXMLCreator("RegistrationResponse");
            $root->setAttribute("xmlns", "urn:Microsoft.Search");
            
            $regres = new CXMLCreator("RegistrationResult");
            $root->addChild($regres);
                        
            $prup = new CXMLCreator("ProviderUpdate");
            $prup->setAttribute("xmlns", "urn:Microsoft.Search.Registration.Response");
            $prup->setAttribute("revision", "1");             
            $prup->setAttribute("build", "1");
            $regres->addChild($prup);
            
            $stat = new CXMLCreator("Status");
            $stat->setData("SUCCESS");
            $prup->addChild($stat);
                        
            $providers = array(
                
                "Provider" => array (
                    "Message" => "Test service.",
                    "Id" => "{$this->provider_id}",
                    "Name" => "Тестовая служба. {$this->add_tittle}",
                    "QueryPath" => $this->query_path,
                    "RegistrationPath" => $this->registration_path,
                    "AboutPath" => "http://www.bitrix.ru/",
                    "Type" => "SOAP",
                    "Revision" => "1",
                    "Services" => array(
                        "Service" => array(
                            "Id" => "{$this->service_id}",
                            "Name" => "Тестовая служба. {$this->add_tittle}",
                            "Description" => "SOAP server test service.",
                            "Copyright" => "(c) Bitrix.",
                            "Display" => "On",
                            "Category" => "ECOMMERCE_GENERAL",
                            "Parental" => "Unsupported",
                        )
                    )                        
                )                    
            
            );

            $providersEncoded = CSOAPRequest::encodeValueLight("Providers", $providers);
            $prup->addChild($providersEncoded);        
            
            ...
            
            return true;
        }
        
        return false;
    }
}
© «Bitrix24», 2001-2024