Documentation

CSOAPServerResponser

Methods

Method Description
void
OnBeforeRequest(
 CSOAPServer &cserver
)
Called on all CSOAPServerResponser based handers registered in a SOAP server when an event fires: after a request has been received but before it is decoded.
void
OnAfterResponse(
 CSOAPServer &cserver
)
Called on all CSOAPServerResponser based handers when an event fires: after a request has been processed and a response has been sent(ProcessRequestBody returned true).
boolean
ProcessRequestBody(
 CSOAPServer &cserver,
 CDataXMLNode body
)
Processes a SOAP server request. If the method has processed a request and called ShowResponse, it returns true. Otherwise, it returns false and the system calls methods ProcessRequestBody of other handlers until the current callee returns true or there is no more handlers to call.

Parameters of methods

Parameter Description
cserver Reference to an instance of CSOAPServer that handles a SOAP request.
body A piece of an XML query following the body tag as CDataXMLNode.

Example



class CMSSOAPResearch extends CSOAPServerResponser
{
    var $provider_id;    
    var $service_id;
    var $add_tittle;
    var $query_path;
    var $registration_path;

    function OnBeforeRequest(&$cserver) 
    {
        AddMessage2Log(mydump($cserver->GetRequestData()));    
    }

    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" => "Oanoiaay neo?aa.",
                    "Id" => "{$this->provider_id}",
                    "Name" => "Oanoiaay neo?aa. {$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" => "Test service. {$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);        
            
            $cserver->ShowRawResponse($root, true);
            
            AddMessage2Log($cserver->GetResponseData());
            
            return true;
        }
        
        return false;
    }
}
© «Bitrix24», 2001-2024