Support Incident Tracker GIT4.x
nusoap_server Class Reference
Inheritance diagram for nusoap_server:
Collaboration diagram for nusoap_server:

Public Member Functions

 nusoap_server ($wsdl=false)
 service ($data)
 parse_http_headers ()
 parse_request ($data='')
 invoke_method ()
 serialize_return ()
 send_response ()
 verify_method ($operation, $request)
 parseRequest ($headers, $data)
 getHTTPBody ($soapmsg)
 getHTTPContentType ()
 getHTTPContentTypeCharset ()
 add_to_map ($methodname, $in, $out)
 register ($name, $in=array(), $out=array(), $namespace=false, $soapaction=false, $style=false, $use=false, $documentation='', $encodingStyle='')
 fault ($faultcode, $faultstring, $faultactor='', $faultdetail='')
 configureWSDL ($serviceName, $namespace=false, $endpoint=false, $style='rpc', $transport= 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace=false)
 nusoap_server ($wsdl=false)
 service ($data)
 parse_http_headers ()
 parse_request ($data='')
 invoke_method ()
 serialize_return ()
 send_response ()
 verify_method ($operation, $request)
 parseRequest ($headers, $data)
 getHTTPBody ($soapmsg)
 getHTTPContentType ()
 getHTTPContentTypeCharset ()
 add_to_map ($methodname, $in, $out)
 register ($name, $in=array(), $out=array(), $namespace=false, $soapaction=false, $style=false, $use=false, $documentation='', $encodingStyle='')
 fault ($faultcode, $faultstring, $faultactor='', $faultdetail='')
 configureWSDL ($serviceName, $namespace=false, $endpoint=false, $style='rpc', $transport= 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace=false)

Data Fields

 $headers = array()
 $request = ''
 $requestHeaders = ''
 $requestHeader = NULL
 $document = ''
 $requestSOAP = ''
 $methodURI = ''
 $methodname = ''
 $methodparams = array()
 $SOAPAction = ''
 $xml_encoding = ''
 $decode_utf8 = true
 $outgoing_headers = array()
 $response = ''
 $responseHeaders = ''
 $responseSOAP = ''
 $methodreturn = false
 $methodreturnisliteralxml = false
 $fault = false
 $result = 'successful'
 $operations = array()
 $wsdl = false
 $externalWSDLURL = false
 $debug_flag = false

Detailed Description

nusoap_server allows the user to create a SOAP server that is capable of receiving messages and returning responses

Author:
Dietrich Ayala <dietrich@ganx4.com>
Scott Nichol <snichol@users.sourceforge.net>
Version:
Id:
class.soap_server.php,v 1.58 2007/10/30 18:50:30 snichol Exp

public

nusoap_server allows the user to create a SOAP server that is capable of receiving messages and returning responses

Author:
Dietrich Ayala <dietrich@ganx4.com>
Scott Nichol <snichol@users.sourceforge.net>
Version:
Id:
nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp

public

Definition at line 16 of file class.soap_server.php.


Member Function Documentation

add_to_map ( methodname,
in,
out 
)

add a method to the dispatch map (this has been replaced by the register method)

Parameters:
string$methodname
string$inarray of input values
string$outarray of output values public
Deprecated:

Definition at line 888 of file class.soap_server.php.

References $methodname.

                                             {
            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
    }
add_to_map ( methodname,
in,
out 
)

add a method to the dispatch map (this has been replaced by the register method)

Parameters:
string$methodname
string$inarray of input values
string$outarray of output values public
Deprecated:

Definition at line 4297 of file nusoap.php.

References $methodname.

                                             {
            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
    }
configureWSDL ( serviceName,
namespace = false,
endpoint = false,
style = 'rpc',
transport = 'http://schemas.xmlsoap.org/soap/http',
schemaTargetNamespace = false 
)

Sets up wsdl object. Acts as a flag to enable internal WSDL generation

Parameters:
string$serviceName,nameof the service
mixed$namespaceoptional 'tns' service namespace or false
mixed$endpointoptional URL of service endpoint or false
string$styleoptional (rpc|document) WSDL style (also specified by operation)
string$transportoptional SOAP transport
mixed$schemaTargetNamespaceoptional 'types' targetNamespace for service schema or false

Definition at line 994 of file class.soap_server.php.

References $_SERVER, elseif, and nusoap_base::setError().

                                                                                                             ://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
    {
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER)) {
            $SERVER_NAME = $_SERVER['SERVER_NAME'];
            $SERVER_PORT = $_SERVER['SERVER_PORT'];
            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
        } elseif (isset($HTTP_SERVER_VARS)) {
            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
        } else {
            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
        }
        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
        $colon = strpos($SERVER_NAME,":");
        if ($colon) {
            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
        }
        if ($SERVER_PORT == 80) {
            $SERVER_PORT = '';
        } else {
            $SERVER_PORT = ':' . $SERVER_PORT;
        }
        if(false == $namespace) {
            $namespace = "http://$SERVER_NAME/soap/$serviceName";
        }
        
        if(false == $endpoint) {
            if ($HTTPS == '1' || $HTTPS == 'on') {
                $SCHEME = 'https';
            } else {
                $SCHEME = 'http';
            }
            $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
        }
        
        if(false == $schemaTargetNamespace) {
            $schemaTargetNamespace = $namespace;
        }
        
        $this->wsdl = new wsdl;
        $this->wsdl->serviceName = $serviceName;
        $this->wsdl->endpoint = $endpoint;
        $this->wsdl->namespaces['tns'] = $namespace;
        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
        if ($schemaTargetNamespace != $namespace) {
            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
        }
        $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
        if ($style == 'document') {
            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
        }
        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
        $this->wsdl->bindings[$serviceName.'Binding'] = array(
            'name'=>$serviceName.'Binding',
            'style'=>$style,
            'transport'=>$transport,
            'portType'=>$serviceName.'PortType');
        $this->wsdl->ports[$serviceName.'Port'] = array(
            'binding'=>$serviceName.'Binding',
            'location'=>$endpoint,
            'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
    }
configureWSDL ( serviceName,
namespace = false,
endpoint = false,
style = 'rpc',
transport = 'http://schemas.xmlsoap.org/soap/http',
schemaTargetNamespace = false 
)

Sets up wsdl object. Acts as a flag to enable internal WSDL generation

Parameters:
string$serviceName,nameof the service
mixed$namespaceoptional 'tns' service namespace or false
mixed$endpointoptional URL of service endpoint or false
string$styleoptional (rpc|document) WSDL style (also specified by operation)
string$transportoptional SOAP transport
mixed$schemaTargetNamespaceoptional 'types' targetNamespace for service schema or false

Definition at line 4403 of file nusoap.php.

References $_SERVER, elseif, and nusoap_base::setError().

                                                                                                             ://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
    {
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER)) {
            $SERVER_NAME = $_SERVER['SERVER_NAME'];
            $SERVER_PORT = $_SERVER['SERVER_PORT'];
            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
        } elseif (isset($HTTP_SERVER_VARS)) {
            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
        } else {
            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
        }
        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
        $colon = strpos($SERVER_NAME,":");
        if ($colon) {
            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
        }
        if ($SERVER_PORT == 80) {
            $SERVER_PORT = '';
        } else {
            $SERVER_PORT = ':' . $SERVER_PORT;
        }
        if(false == $namespace) {
            $namespace = "http://$SERVER_NAME/soap/$serviceName";
        }
        
        if(false == $endpoint) {
            if ($HTTPS == '1' || $HTTPS == 'on') {
                $SCHEME = 'https';
            } else {
                $SCHEME = 'http';
            }
            $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
        }
        
        if(false == $schemaTargetNamespace) {
            $schemaTargetNamespace = $namespace;
        }
        
        $this->wsdl = new wsdl;
        $this->wsdl->serviceName = $serviceName;
        $this->wsdl->endpoint = $endpoint;
        $this->wsdl->namespaces['tns'] = $namespace;
        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
        if ($schemaTargetNamespace != $namespace) {
            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
        }
        $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
        if ($style == 'document') {
            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
        }
        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
        $this->wsdl->bindings[$serviceName.'Binding'] = array(
            'name'=>$serviceName.'Binding',
            'style'=>$style,
            'transport'=>$transport,
            'portType'=>$serviceName.'PortType');
        $this->wsdl->ports[$serviceName.'Port'] = array(
            'binding'=>$serviceName.'Binding',
            'location'=>$endpoint,
            'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
    }
fault ( faultcode,
faultstring,
faultactor = '',
faultdetail = '' 
)

Specify a fault to be returned to the client. This also acts as a flag to the server that a fault has occured.

Parameters:
string$faultcode
string$faultstring
string$faultactor
string$faultdetailpublic

Definition at line 975 of file class.soap_server.php.

References nusoap_base::getDebug().

Referenced by fault(), invoke_method(), parse_request(), parseRequest(), send_response(), serialize_return(), and service().

                                                                          {
        if ($faultdetail == '' && $this->debug_flag) {
            $faultdetail = $this->getDebug();
        }
        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
        $this->fault->soap_defencoding = $this->soap_defencoding;
    }
fault ( faultcode,
faultstring,
faultactor = '',
faultdetail = '' 
)

Specify a fault to be returned to the client. This also acts as a flag to the server that a fault has occured.

Parameters:
string$faultcode
string$faultstring
string$faultactor
string$faultdetailpublic

Definition at line 4384 of file nusoap.php.

References fault(), and nusoap_base::getDebug().

                                                                          {
        if ($faultdetail == '' && $this->debug_flag) {
            $faultdetail = $this->getDebug();
        }
        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
        $this->fault->soap_defencoding = $this->soap_defencoding;
    }
getHTTPBody ( soapmsg)

gets the HTTP body for the current response.

Parameters:
string$soapmsgThe SOAP payload
Returns:
string The HTTP body, which includes the SOAP payload private

Reimplemented in nusoap_server_mime.

Definition at line 4259 of file nusoap.php.

                                   {
        return $soapmsg;
    }
getHTTPBody ( soapmsg)

gets the HTTP body for the current response.

Parameters:
string$soapmsgThe SOAP payload
Returns:
string The HTTP body, which includes the SOAP payload private

Reimplemented in nusoap_server_mime.

Definition at line 850 of file class.soap_server.php.

Referenced by send_response().

                                   {
        return $soapmsg;
    }
getHTTPContentType ( )

gets the HTTP content type for the current response.

Note: getHTTPBody must be called before this.

Returns:
string the HTTP content type for the current response. private

Reimplemented in nusoap_server_mime.

Definition at line 862 of file class.soap_server.php.

Referenced by send_response().

                                  {
        return 'text/xml';
    }
getHTTPContentType ( )

gets the HTTP content type for the current response.

Note: getHTTPBody must be called before this.

Returns:
string the HTTP content type for the current response. private

Reimplemented in nusoap_server_mime.

Definition at line 4271 of file nusoap.php.

                                  {
        return 'text/xml';
    }
getHTTPContentTypeCharset ( )

gets the HTTP content type charset for the current response. returns false for non-text content types.

Note: getHTTPBody must be called before this.

Returns:
string the HTTP content type charset for the current response. private

Reimplemented in nusoap_server_mime.

Definition at line 875 of file class.soap_server.php.

Referenced by send_response().

                                         {
        return $this->soap_defencoding;
    }
getHTTPContentTypeCharset ( )

gets the HTTP content type charset for the current response. returns false for non-text content types.

Note: getHTTPBody must be called before this.

Returns:
string the HTTP content type charset for the current response. private

Reimplemented in nusoap_server_mime.

Definition at line 4284 of file nusoap.php.

                                         {
        return $this->soap_defencoding;
    }
invoke_method ( )

invokes a PHP function for the requested SOAP method

The following fields are set by this function (when successful)

methodreturn

Note that the PHP function that is called may also set the following fields to affect the response sent to the client

responseHeaders outgoing_headers

This sets the fault field on error

private

Definition at line 471 of file class.soap_server.php.

References $class, nusoap_base::appendDebug(), nusoap_base::debug(), elseif, fault(), wsdl::getOperationData(), wsdl::getOperationDataForSoapAction(), nusoap_base::varDump(), and verify_method().

Referenced by service().

                             {
        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);

        if ($this->wsdl) {
            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
                $this->appendDebug('opData=' . $this->varDump($this->opData));
            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
                $this->appendDebug('opData=' . $this->varDump($this->opData));
                $this->methodname = $this->opData['name'];
            } else {
                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
                return;
            }
        } else {
            $this->debug('in invoke_method, no WSDL to validate method');
        }

        // if a . is present in $this->methodname, we see if there is a class in scope,
        // which could be referred to. We will also distinguish between two deliminators,
        // to allow methods to be called a the class or an instance
        $class = '';
        $method = '';
        if (strpos($this->methodname, '..') > 0) {
            $delim = '..';
        } else if (strpos($this->methodname, '.') > 0) {
            $delim = '.';
        } else {
            $delim = '';
        }

        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
            class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
            // get the class and method name
            $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
            $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
            $this->debug("in invoke_method, class=$class method=$method delim=$delim");
        }

        // does method exist?
        if ($class == '') {
            if (!function_exists($this->methodname)) {
                $this->debug("in invoke_method, function '$this->methodname' not found!");
                $this->result = 'fault: method not found';
                $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
                return;
            }
        } else {
            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
            if (!in_array($method_to_compare, get_class_methods($class))) {
                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
                $this->result = 'fault: method not found';
                $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
                return;
            }
        }

        // evaluate message, getting back parameters
        // verify that request parameters match the method's signature
        if(! $this->verify_method($this->methodname,$this->methodparams)){
            // debug
            $this->debug('ERROR: request not verified against method signature');
            $this->result = 'fault: request failed validation against method signature';
            // return fault
            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
            return;
        }

        // if there are parameters to pass
        $this->debug('in invoke_method, params:');
        $this->appendDebug($this->varDump($this->methodparams));
        $this->debug("in invoke_method, calling '$this->methodname'");
        if (!function_exists('call_user_func_array')) {
            if ($class == '') {
                $this->debug('in invoke_method, calling function using eval()');
                $funcCall = "\$this->methodreturn = $this->methodname(";
            } else {
                if ($delim == '..') {
                    $this->debug('in invoke_method, calling class method using eval()');
                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
                } else {
                    $this->debug('in invoke_method, calling instance method using eval()');
                    // generate unique instance name
                    $instname = "\$inst_".time();
                    $funcCall = $instname." = new ".$class."(); ";
                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
                }
            }
            if ($this->methodparams) {
                foreach ($this->methodparams as $param) {
                    if (is_array($param) || is_object($param)) {
                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
                        return;
                    }
                    $funcCall .= "\"$param\",";
                }
                $funcCall = substr($funcCall, 0, -1);
            }
            $funcCall .= ');';
            $this->debug('in invoke_method, function call: '.$funcCall);
            @eval($funcCall);
        } else {
            if ($class == '') {
                $this->debug('in invoke_method, calling function using call_user_func_array()');
                $call_arg = "$this->methodname";    // straight assignment changes $this->methodname to lower case after call_user_func_array()
            } elseif ($delim == '..') {
                $this->debug('in invoke_method, calling class method using call_user_func_array()');
                $call_arg = array ($class, $method);
            } else {
                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
                $instance = new $class ();
                $call_arg = array(&$instance, $method);
            }
            if (is_array($this->methodparams)) {
                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
            } else {
                $this->methodreturn = call_user_func_array($call_arg, array());
            }
        }
        $this->debug('in invoke_method, methodreturn:');
        $this->appendDebug($this->varDump($this->methodreturn));
        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
    }
invoke_method ( )

invokes a PHP function for the requested SOAP method

The following fields are set by this function (when successful)

methodreturn

Note that the PHP function that is called may also set the following fields to affect the response sent to the client

responseHeaders outgoing_headers

This sets the fault field on error

private

Definition at line 3880 of file nusoap.php.

References $class, nusoap_base::appendDebug(), nusoap_base::debug(), elseif, fault(), wsdl::getOperationData(), wsdl::getOperationDataForSoapAction(), nusoap_base::varDump(), and verify_method().

                             {
        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);

        if ($this->wsdl) {
            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
                $this->appendDebug('opData=' . $this->varDump($this->opData));
            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
                $this->appendDebug('opData=' . $this->varDump($this->opData));
                $this->methodname = $this->opData['name'];
            } else {
                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
                return;
            }
        } else {
            $this->debug('in invoke_method, no WSDL to validate method');
        }

        // if a . is present in $this->methodname, we see if there is a class in scope,
        // which could be referred to. We will also distinguish between two deliminators,
        // to allow methods to be called a the class or an instance
        $class = '';
        $method = '';
        if (strpos($this->methodname, '..') > 0) {
            $delim = '..';
        } else if (strpos($this->methodname, '.') > 0) {
            $delim = '.';
        } else {
            $delim = '';
        }

        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
            class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
            // get the class and method name
            $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
            $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
            $this->debug("in invoke_method, class=$class method=$method delim=$delim");
        }

        // does method exist?
        if ($class == '') {
            if (!function_exists($this->methodname)) {
                $this->debug("in invoke_method, function '$this->methodname' not found!");
                $this->result = 'fault: method not found';
                $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
                return;
            }
        } else {
            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
            if (!in_array($method_to_compare, get_class_methods($class))) {
                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
                $this->result = 'fault: method not found';
                $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
                return;
            }
        }

        // evaluate message, getting back parameters
        // verify that request parameters match the method's signature
        if(! $this->verify_method($this->methodname,$this->methodparams)){
            // debug
            $this->debug('ERROR: request not verified against method signature');
            $this->result = 'fault: request failed validation against method signature';
            // return fault
            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
            return;
        }

        // if there are parameters to pass
        $this->debug('in invoke_method, params:');
        $this->appendDebug($this->varDump($this->methodparams));
        $this->debug("in invoke_method, calling '$this->methodname'");
        if (!function_exists('call_user_func_array')) {
            if ($class == '') {
                $this->debug('in invoke_method, calling function using eval()');
                $funcCall = "\$this->methodreturn = $this->methodname(";
            } else {
                if ($delim == '..') {
                    $this->debug('in invoke_method, calling class method using eval()');
                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
                } else {
                    $this->debug('in invoke_method, calling instance method using eval()');
                    // generate unique instance name
                    $instname = "\$inst_".time();
                    $funcCall = $instname." = new ".$class."(); ";
                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
                }
            }
            if ($this->methodparams) {
                foreach ($this->methodparams as $param) {
                    if (is_array($param) || is_object($param)) {
                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
                        return;
                    }
                    $funcCall .= "\"$param\",";
                }
                $funcCall = substr($funcCall, 0, -1);
            }
            $funcCall .= ');';
            $this->debug('in invoke_method, function call: '.$funcCall);
            @eval($funcCall);
        } else {
            if ($class == '') {
                $this->debug('in invoke_method, calling function using call_user_func_array()');
                $call_arg = "$this->methodname";    // straight assignment changes $this->methodname to lower case after call_user_func_array()
            } elseif ($delim == '..') {
                $this->debug('in invoke_method, calling class method using call_user_func_array()');
                $call_arg = array ($class, $method);
            } else {
                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
                $instance = new $class ();
                $call_arg = array(&$instance, $method);
            }
            if (is_array($this->methodparams)) {
                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
            } else {
                $this->methodreturn = call_user_func_array($call_arg, array());
            }
        }
        $this->debug('in invoke_method, methodreturn:');
        $this->appendDebug($this->varDump($this->methodreturn));
        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
    }
nusoap_server ( wsdl = false)

constructor the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.

Parameters:
mixed$wsdlfile path or URL (string), or wsdl instance (object) public

Definition at line 3582 of file nusoap.php.

References $_SERVER, $wsdl, nusoap_base::appendDebug(), nusoap_base::clearDebug(), nusoap_base::debug(), elseif, nusoap_base::getDebug(), nusoap_base::getError(), nusoap_base::nusoap_base(), nusoap_base::varDump(), and wsdl::wsdl().

                                       {
        parent::nusoap_base();
        // turn on debugging?
        global $debug;
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER)) {
            $this->debug("_SERVER is defined:");
            $this->appendDebug($this->varDump($_SERVER));
        } elseif (isset($HTTP_SERVER_VARS)) {
            $this->debug("HTTP_SERVER_VARS is defined:");
            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
        } else {
            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
        }

        if (isset($debug)) {
            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
            $this->debug_flag = $debug;
        } elseif (isset($_SERVER['QUERY_STRING'])) {
            $qs = explode('&', $_SERVER['QUERY_STRING']);
            foreach ($qs as $v) {
                if (substr($v, 0, 6) == 'debug=') {
                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
                    $this->debug_flag = substr($v, 6);
                }
            }
        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
            foreach ($qs as $v) {
                if (substr($v, 0, 6) == 'debug=') {
                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
                    $this->debug_flag = substr($v, 6);
                }
            }
        }

        // wsdl
        if($wsdl){
            $this->debug("In nusoap_server, WSDL is specified");
            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
                $this->wsdl = $wsdl;
                $this->externalWSDLURL = $this->wsdl->wsdl;
                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
            } else {
                $this->debug('Create wsdl from ' . $wsdl);
                $this->wsdl = new wsdl($wsdl);
                $this->externalWSDLURL = $wsdl;
            }
            $this->appendDebug($this->wsdl->getDebug());
            $this->wsdl->clearDebug();
            if($err = $this->wsdl->getError()){
                die('WSDL ERROR: '.$err);
            }
        }
    }
nusoap_server ( wsdl = false)

constructor the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.

Parameters:
mixed$wsdlfile path or URL (string), or wsdl instance (object) public

Definition at line 173 of file class.soap_server.php.

References $_SERVER, $wsdl, nusoap_base::appendDebug(), nusoap_base::clearDebug(), nusoap_base::debug(), elseif, nusoap_base::getDebug(), nusoap_base::getError(), nusoap_base::nusoap_base(), nusoap_base::varDump(), and wsdl::wsdl().

                                       {
        parent::nusoap_base();
        // turn on debugging?
        global $debug;
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER)) {
            $this->debug("_SERVER is defined:");
            $this->appendDebug($this->varDump($_SERVER));
        } elseif (isset($HTTP_SERVER_VARS)) {
            $this->debug("HTTP_SERVER_VARS is defined:");
            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
        } else {
            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
        }

        if (isset($debug)) {
            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
            $this->debug_flag = $debug;
        } elseif (isset($_SERVER['QUERY_STRING'])) {
            $qs = explode('&', $_SERVER['QUERY_STRING']);
            foreach ($qs as $v) {
                if (substr($v, 0, 6) == 'debug=') {
                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
                    $this->debug_flag = substr($v, 6);
                }
            }
        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
            foreach ($qs as $v) {
                if (substr($v, 0, 6) == 'debug=') {
                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
                    $this->debug_flag = substr($v, 6);
                }
            }
        }

        // wsdl
        if($wsdl){
            $this->debug("In nusoap_server, WSDL is specified");
            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
                $this->wsdl = $wsdl;
                $this->externalWSDLURL = $this->wsdl->wsdl;
                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
            } else {
                $this->debug('Create wsdl from ' . $wsdl);
                $this->wsdl = new wsdl($wsdl);
                $this->externalWSDLURL = $wsdl;
            }
            $this->appendDebug($this->wsdl->getDebug());
            $this->wsdl->clearDebug();
            if($err = $this->wsdl->getError()){
                die('WSDL ERROR: '.$err);
            }
        }
    }
parse_http_headers ( )

parses HTTP request headers.

The following fields are set by this function (when successful)

headers request xml_encoding SOAPAction

private

Definition at line 3707 of file nusoap.php.

References $_SERVER, $headers, nusoap_base::debug(), elseif, and nusoap_base::setError().

                                  {
        global $HTTP_SERVER_VARS;

        $this->request = '';
        $this->SOAPAction = '';
        if(function_exists('getallheaders')){
            $this->debug("In parse_http_headers, use getallheaders");
            $headers = getallheaders();
            foreach($headers as $k=>$v){
                $k = strtolower($k);
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
            // get SOAPAction header
            if(isset($this->headers['soapaction'])){
                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
            }
            // get the character encoding of the incoming request
            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
                if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
                    $this->xml_encoding = strtoupper($enc);
                } else {
                    $this->xml_encoding = 'US-ASCII';
                }
            } else {
                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                $this->xml_encoding = 'ISO-8859-1';
            }
        } elseif(isset($_SERVER) && is_array($_SERVER)){
            $this->debug("In parse_http_headers, use _SERVER");
            foreach ($_SERVER as $k => $v) {
                if (substr($k, 0, 5) == 'HTTP_') {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
                } else {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
                }
                if ($k == 'soapaction') {
                    // get SOAPAction header
                    $k = 'SOAPAction';
                    $v = str_replace('"', '', $v);
                    $v = str_replace('\\', '', $v);
                    $this->SOAPAction = $v;
                } else if ($k == 'content-type') {
                    // get the character encoding of the incoming request
                    if (strpos($v, '=')) {
                        $enc = substr(strstr($v, '='), 1);
                        $enc = str_replace('"', '', $enc);
                        $enc = str_replace('\\', '', $enc);
                        if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
                            $this->xml_encoding = strtoupper($enc);
                        } else {
                            $this->xml_encoding = 'US-ASCII';
                        }
                    } else {
                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                        $this->xml_encoding = 'ISO-8859-1';
                    }
                }
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
        } elseif (is_array($HTTP_SERVER_VARS)) {
            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
            foreach ($HTTP_SERVER_VARS as $k => $v) {
                if (substr($k, 0, 5) == 'HTTP_') {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));                                            $k = strtolower(substr($k, 5));
                } else {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));                                           $k = strtolower($k);
                }
                if ($k == 'soapaction') {
                    // get SOAPAction header
                    $k = 'SOAPAction';
                    $v = str_replace('"', '', $v);
                    $v = str_replace('\\', '', $v);
                    $this->SOAPAction = $v;
                } else if ($k == 'content-type') {
                    // get the character encoding of the incoming request
                    if (strpos($v, '=')) {
                        $enc = substr(strstr($v, '='), 1);
                        $enc = str_replace('"', '', $enc);
                        $enc = str_replace('\\', '', $enc);
                        if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
                            $this->xml_encoding = strtoupper($enc);
                        } else {
                            $this->xml_encoding = 'US-ASCII';
                        }
                    } else {
                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                        $this->xml_encoding = 'ISO-8859-1';
                    }
                }
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
        } else {
            $this->debug("In parse_http_headers, HTTP headers not accessible");
            $this->setError("HTTP headers not accessible");
        }
    }
parse_http_headers ( )

parses HTTP request headers.

The following fields are set by this function (when successful)

headers request xml_encoding SOAPAction

private

Definition at line 298 of file class.soap_server.php.

References $_SERVER, $headers, nusoap_base::debug(), elseif, and nusoap_base::setError().

Referenced by parse_request().

                                  {
        global $HTTP_SERVER_VARS;

        $this->request = '';
        $this->SOAPAction = '';
        if(function_exists('getallheaders')){
            $this->debug("In parse_http_headers, use getallheaders");
            $headers = getallheaders();
            foreach($headers as $k=>$v){
                $k = strtolower($k);
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
            // get SOAPAction header
            if(isset($this->headers['soapaction'])){
                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
            }
            // get the character encoding of the incoming request
            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
                if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
                    $this->xml_encoding = strtoupper($enc);
                } else {
                    $this->xml_encoding = 'US-ASCII';
                }
            } else {
                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                $this->xml_encoding = 'ISO-8859-1';
            }
        } elseif(isset($_SERVER) && is_array($_SERVER)){
            $this->debug("In parse_http_headers, use _SERVER");
            foreach ($_SERVER as $k => $v) {
                if (substr($k, 0, 5) == 'HTTP_') {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
                } else {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
                }
                if ($k == 'soapaction') {
                    // get SOAPAction header
                    $k = 'SOAPAction';
                    $v = str_replace('"', '', $v);
                    $v = str_replace('\\', '', $v);
                    $this->SOAPAction = $v;
                } else if ($k == 'content-type') {
                    // get the character encoding of the incoming request
                    if (strpos($v, '=')) {
                        $enc = substr(strstr($v, '='), 1);
                        $enc = str_replace('"', '', $enc);
                        $enc = str_replace('\\', '', $enc);
                        if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
                            $this->xml_encoding = strtoupper($enc);
                        } else {
                            $this->xml_encoding = 'US-ASCII';
                        }
                    } else {
                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                        $this->xml_encoding = 'ISO-8859-1';
                    }
                }
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
        } elseif (is_array($HTTP_SERVER_VARS)) {
            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
            foreach ($HTTP_SERVER_VARS as $k => $v) {
                if (substr($k, 0, 5) == 'HTTP_') {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));                                            $k = strtolower(substr($k, 5));
                } else {
                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));                                           $k = strtolower($k);
                }
                if ($k == 'soapaction') {
                    // get SOAPAction header
                    $k = 'SOAPAction';
                    $v = str_replace('"', '', $v);
                    $v = str_replace('\\', '', $v);
                    $this->SOAPAction = $v;
                } else if ($k == 'content-type') {
                    // get the character encoding of the incoming request
                    if (strpos($v, '=')) {
                        $enc = substr(strstr($v, '='), 1);
                        $enc = str_replace('"', '', $enc);
                        $enc = str_replace('\\', '', $enc);
                        if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
                            $this->xml_encoding = strtoupper($enc);
                        } else {
                            $this->xml_encoding = 'US-ASCII';
                        }
                    } else {
                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
                        $this->xml_encoding = 'ISO-8859-1';
                    }
                }
                $this->headers[$k] = $v;
                $this->request .= "$k: $v\r\n";
                $this->debug("$k: $v");
            }
        } else {
            $this->debug("In parse_http_headers, HTTP headers not accessible");
            $this->setError("HTTP headers not accessible");
        }
    }
parse_request ( data = '')

parses a request

The following fields are set by this function (when successful)

headers request xml_encoding SOAPAction request requestSOAP methodURI methodname methodparams requestHeaders document

This sets the fault field on error

Parameters:
string$dataXML string private

Definition at line 3833 of file nusoap.php.

References $data, nusoap_base::debug(), elseif, fault(), parse_http_headers(), and parseRequest().

                                     {
        $this->debug('entering parse_request()');
        $this->parse_http_headers();
        $this->debug('got character encoding: '.$this->xml_encoding);
        // uncompress if necessary
        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
                // if decoding works, use it. else assume data wasn't gzencoded
                if (function_exists('gzuncompress')) {
                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
                        $data = $degzdata;
                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
                        $data = $degzdata;
                    } else {
                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
                        return;
                    }
                } else {
                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
                    return;
                }
            }
        }
        $this->request .= "\r\n".$data;
        $data = $this->parseRequest($this->headers, $data);
        $this->requestSOAP = $data;
        $this->debug('leaving parse_request');
    }
parse_request ( data = '')

parses a request

The following fields are set by this function (when successful)

headers request xml_encoding SOAPAction request requestSOAP methodURI methodname methodparams requestHeaders document

This sets the fault field on error

Parameters:
string$dataXML string private

Definition at line 424 of file class.soap_server.php.

References $data, nusoap_base::debug(), elseif, fault(), parse_http_headers(), and parseRequest().

Referenced by service().

                                     {
        $this->debug('entering parse_request()');
        $this->parse_http_headers();
        $this->debug('got character encoding: '.$this->xml_encoding);
        // uncompress if necessary
        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
                // if decoding works, use it. else assume data wasn't gzencoded
                if (function_exists('gzuncompress')) {
                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
                        $data = $degzdata;
                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
                        $data = $degzdata;
                    } else {
                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
                        return;
                    }
                } else {
                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
                    return;
                }
            }
        }
        $this->request .= "\r\n".$data;
        $data = $this->parseRequest($this->headers, $data);
        $this->requestSOAP = $data;
        $this->debug('leaving parse_request');
    }
parseRequest ( headers,
data 
)

processes SOAP message received from client

Parameters:
array$headersThe HTTP headers
string$dataunprocessed request data from client
Returns:
mixed value of the message, decoded into a PHP type private

Reimplemented in nusoap_server_mime.

Definition at line 799 of file class.soap_server.php.

References $data, $headers, nusoap_base::debug(), fault(), and nusoap_base::setError().

Referenced by parse_request().

                                           {
        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $headers['content-type']);
        if (!strstr($headers['content-type'], 'text/xml')) {
            $this->setError('Request not of type text/xml');
            return false;
        }
        if (strpos($headers['content-type'], '=')) {
            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
            $this->debug('Got response encoding: ' . $enc);
            if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
                $this->xml_encoding = strtoupper($enc);
            } else {
                $this->xml_encoding = 'US-ASCII';
            }
        } else {
            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
            $this->xml_encoding = 'ISO-8859-1';
        }
        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
        // parse response, get soap parser obj
        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
        // parser debug
        $this->debug("parser debug: \n".$parser->getDebug());
        // if fault occurred during message parsing
        if($err = $parser->getError()){
            $this->result = 'fault: error in msg parsing: '.$err;
            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
        // else successfully parsed request into soapval object
        } else {
            // get/set methodname
            $this->methodURI = $parser->root_struct_namespace;
            $this->methodname = $parser->root_struct_name;
            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
            $this->debug('calling parser->get_soapbody()');
            $this->methodparams = $parser->get_soapbody();
            // get SOAP headers
            $this->requestHeaders = $parser->getHeaders();
            // get SOAP Header
            $this->requestHeader = $parser->get_soapheader();
            // add document for doclit support
            $this->document = $parser->document;
        }
     }
parseRequest ( headers,
data 
)

processes SOAP message received from client

Parameters:
array$headersThe HTTP headers
string$dataunprocessed request data from client
Returns:
mixed value of the message, decoded into a PHP type private

Reimplemented in nusoap_server_mime.

Definition at line 4208 of file nusoap.php.

References $data, $headers, nusoap_base::debug(), fault(), and nusoap_base::setError().

                                           {
        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $headers['content-type']);
        if (!strstr($headers['content-type'], 'text/xml')) {
            $this->setError('Request not of type text/xml');
            return false;
        }
        if (strpos($headers['content-type'], '=')) {
            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
            $this->debug('Got response encoding: ' . $enc);
            if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
                $this->xml_encoding = strtoupper($enc);
            } else {
                $this->xml_encoding = 'US-ASCII';
            }
        } else {
            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
            $this->xml_encoding = 'ISO-8859-1';
        }
        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
        // parse response, get soap parser obj
        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
        // parser debug
        $this->debug("parser debug: \n".$parser->getDebug());
        // if fault occurred during message parsing
        if($err = $parser->getError()){
            $this->result = 'fault: error in msg parsing: '.$err;
            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
        // else successfully parsed request into soapval object
        } else {
            // get/set methodname
            $this->methodURI = $parser->root_struct_namespace;
            $this->methodname = $parser->root_struct_name;
            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
            $this->debug('calling parser->get_soapbody()');
            $this->methodparams = $parser->get_soapbody();
            // get SOAP headers
            $this->requestHeaders = $parser->getHeaders();
            // get SOAP Header
            $this->requestHeader = $parser->get_soapheader();
            // add document for doclit support
            $this->document = $parser->document;
        }
     }
register ( name,
in = array(),
out = array(),
namespace = false,
soapaction = false,
style = false,
use = false,
documentation = '',
encodingStyle = '' 
)

register a service function with the server

Parameters:
string$namethe name of the PHP function, class.method or class..method
array$inassoc array of input values: key = param name, value = param type
array$outassoc array of output values: key = param name, value = param type
mixed$namespacethe element namespace for the method or false
mixed$soapactionthe soapaction for the method or false
mixed$styleoptional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
mixed$useoptional (encoded|literal) or false
string$documentationoptional Description to include in WSDL
string$encodingStyleoptional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) public

Definition at line 906 of file class.soap_server.php.

References $_SERVER, wsdl::addOperation(), elseif, and nusoap_base::setError().

                                                                                                                                                    {
        global $HTTP_SERVER_VARS;

        if($this->externalWSDLURL){
            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
        }
        if (! $name) {
            die('You must specify a name when you register an operation');
        }
        if (!is_array($in)) {
            die('You must provide an array for operation inputs');
        }
        if (!is_array($out)) {
            die('You must provide an array for operation outputs');
        }
        if(false == $namespace) {
        }
        if(false == $soapaction) {
            if (isset($_SERVER)) {
                $SERVER_NAME = $_SERVER['SERVER_NAME'];
                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
            } elseif (isset($HTTP_SERVER_VARS)) {
                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
            } else {
                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
            }
            if ($HTTPS == '1' || $HTTPS == 'on') {
                $SCHEME = 'https';
            } else {
                $SCHEME = 'http';
            }
            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
        }
        if(false == $style) {
            $style = "rpc";
        }
        if(false == $use) {
            $use = "encoded";
        }
        if ($use == 'encoded' && $encodingStyle = '') {
            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
        }

        $this->operations[$name] = array(
        'name' => $name,
        'in' => $in,
        'out' => $out,
        'namespace' => $namespace,
        'soapaction' => $soapaction,
        'style' => $style);
        if($this->wsdl){
            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
        }
        return true;
    }
register ( name,
in = array(),
out = array(),
namespace = false,
soapaction = false,
style = false,
use = false,
documentation = '',
encodingStyle = '' 
)

register a service function with the server

Parameters:
string$namethe name of the PHP function, class.method or class..method
array$inassoc array of input values: key = param name, value = param type
array$outassoc array of output values: key = param name, value = param type
mixed$namespacethe element namespace for the method or false
mixed$soapactionthe soapaction for the method or false
mixed$styleoptional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
mixed$useoptional (encoded|literal) or false
string$documentationoptional Description to include in WSDL
string$encodingStyleoptional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) public

Definition at line 4315 of file nusoap.php.

References $_SERVER, wsdl::addOperation(), elseif, and nusoap_base::setError().

                                                                                                                                                    {
        global $HTTP_SERVER_VARS;

        if($this->externalWSDLURL){
            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
        }
        if (! $name) {
            die('You must specify a name when you register an operation');
        }
        if (!is_array($in)) {
            die('You must provide an array for operation inputs');
        }
        if (!is_array($out)) {
            die('You must provide an array for operation outputs');
        }
        if(false == $namespace) {
        }
        if(false == $soapaction) {
            if (isset($_SERVER)) {
                $SERVER_NAME = $_SERVER['SERVER_NAME'];
                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
            } elseif (isset($HTTP_SERVER_VARS)) {
                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
            } else {
                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
            }
            if ($HTTPS == '1' || $HTTPS == 'on') {
                $SCHEME = 'https';
            } else {
                $SCHEME = 'http';
            }
            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
        }
        if(false == $style) {
            $style = "rpc";
        }
        if(false == $use) {
            $use = "encoded";
        }
        if ($use == 'encoded' && $encodingStyle = '') {
            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
        }

        $this->operations[$name] = array(
        'name' => $name,
        'in' => $in,
        'out' => $out,
        'namespace' => $namespace,
        'soapaction' => $soapaction,
        'style' => $style);
        if($this->wsdl){
            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
        }
        return true;
    }
send_response ( )

sends an HTTP response

The following fields are set by this function (when successful)

outgoing_headers response

private

Definition at line 701 of file class.soap_server.php.

References $type, nusoap_base::debug(), elseif, fault(), nusoap_base::getDebugAsXMLComment(), getHTTPBody(), getHTTPContentType(), and getHTTPContentTypeCharset().

Referenced by service().

                             {
        $this->debug('Enter send_response');
        if ($this->fault) {
            $payload = $this->fault->serialize();
            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
        } else {
            $payload = $this->responseSOAP;
            // Some combinations of PHP+Web server allow the Status
            // to come through as a header.  Since OK is the default
            // just do nothing.
            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
            // $this->outgoing_headers[] = "Status: 200 OK";
        }
        // add debug data if in debug mode
        if(isset($this->debug_flag) && $this->debug_flag){
            $payload .= $this->getDebugAsXMLComment();
        }
        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
        ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
        // Let the Web server decide about this
        //$this->outgoing_headers[] = "Connection: Close\r\n";
        $payload = $this->getHTTPBody($payload);
        $type = $this->getHTTPContentType();
        $charset = $this->getHTTPContentTypeCharset();
        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
        //begin code to compress payload - by John
        // NOTE: there is no way to know whether the Web server will also compress
        // this data.
        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { 
            if (strstr($this->headers['accept-encoding'], 'gzip')) {
                if (function_exists('gzencode')) {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content being gzipped -->";
                    }
                    $this->outgoing_headers[] = "Content-Encoding: gzip";
                    $payload = gzencode($payload);
                } else {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
                    }
                }
            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
                // instead of gzcompress output,
                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
                if (function_exists('gzdeflate')) {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content being deflated -->";
                    }
                    $this->outgoing_headers[] = "Content-Encoding: deflate";
                    $payload = gzdeflate($payload);
                } else {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
                    }
                }
            }
        }
        //end code
        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
        reset($this->outgoing_headers);
        foreach($this->outgoing_headers as $hdr){
            header($hdr, false);
        }
        print $payload;
        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
    }
send_response ( )

sends an HTTP response

The following fields are set by this function (when successful)

outgoing_headers response

private

Definition at line 4110 of file nusoap.php.

References $type, nusoap_base::debug(), elseif, fault(), nusoap_base::getDebugAsXMLComment(), getHTTPBody(), getHTTPContentType(), and getHTTPContentTypeCharset().

                             {
        $this->debug('Enter send_response');
        if ($this->fault) {
            $payload = $this->fault->serialize();
            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
        } else {
            $payload = $this->responseSOAP;
            // Some combinations of PHP+Web server allow the Status
            // to come through as a header.  Since OK is the default
            // just do nothing.
            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
            // $this->outgoing_headers[] = "Status: 200 OK";
        }
        // add debug data if in debug mode
        if(isset($this->debug_flag) && $this->debug_flag){
            $payload .= $this->getDebugAsXMLComment();
        }
        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
        ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
        // Let the Web server decide about this
        //$this->outgoing_headers[] = "Connection: Close\r\n";
        $payload = $this->getHTTPBody($payload);
        $type = $this->getHTTPContentType();
        $charset = $this->getHTTPContentTypeCharset();
        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
        //begin code to compress payload - by John
        // NOTE: there is no way to know whether the Web server will also compress
        // this data.
        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { 
            if (strstr($this->headers['accept-encoding'], 'gzip')) {
                if (function_exists('gzencode')) {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content being gzipped -->";
                    }
                    $this->outgoing_headers[] = "Content-Encoding: gzip";
                    $payload = gzencode($payload);
                } else {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
                    }
                }
            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
                // instead of gzcompress output,
                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
                if (function_exists('gzdeflate')) {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content being deflated -->";
                    }
                    $this->outgoing_headers[] = "Content-Encoding: deflate";
                    $payload = gzdeflate($payload);
                } else {
                    if (isset($this->debug_flag) && $this->debug_flag) {
                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
                    }
                }
            }
        }
        //end code
        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
        reset($this->outgoing_headers);
        foreach($this->outgoing_headers as $hdr){
            header($hdr, false);
        }
        print $payload;
        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
    }
serialize_return ( )

serializes the return value from a PHP function into a full SOAP Envelope

The following fields are set by this function (when successful)

responseSOAP

This sets the fault field on error

private

Definition at line 609 of file class.soap_server.php.

References nusoap_base::appendDebug(), nusoap_base::clearDebug(), nusoap_base::debug(), elseif, fault(), nusoap_base::getDebug(), nusoap_base::getError(), nusoap_base::serialize_val(), nusoap_base::serializeEnvelope(), wsdl::serializeRPCParameters(), and nusoap_base::varDump().

Referenced by service().

                                {
        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
        // if fault
        if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
            $this->debug('got a fault object from method');
            $this->fault = $this->methodreturn;
            return;
        } elseif ($this->methodreturnisliteralxml) {
            $return_val = $this->methodreturn;
        // returned value(s)
        } else {
            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
            $this->debug('serializing return value');
            if($this->wsdl){
                if (sizeof($this->opData['output']['parts']) > 1) {
                    $this->debug('more than one output part, so use the method return unchanged');
                    $opParams = $this->methodreturn;
                } elseif (sizeof($this->opData['output']['parts']) == 1) {
                    $this->debug('exactly one output part, so wrap the method return in a simple array');
                    // TODO: verify that it is not already wrapped!
                    //foreach ($this->opData['output']['parts'] as $name => $type) {
                    //  $this->debug('wrap in element named ' . $name);
                    //}
                    $opParams = array($this->methodreturn);
                }
                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
                $this->appendDebug($this->wsdl->getDebug());
                $this->wsdl->clearDebug();
                if($errstr = $this->wsdl->getError()){
                    $this->debug('got wsdl error: '.$errstr);
                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
                    return;
                }
            } else {
                if (isset($this->methodreturn)) {
                    $return_val = $this->serialize_val($this->methodreturn, 'return');
                } else {
                    $return_val = '';
                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
                }
            }
        }
        $this->debug('return value:');
        $this->appendDebug($this->varDump($return_val));

        $this->debug('serializing response');
        if ($this->wsdl) {
            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
            if ($this->opData['style'] == 'rpc') {
                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
                if ($this->opData['output']['use'] == 'literal') {
                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
                    $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
                } else {
                    $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
                }
            } else {
                $this->debug('style is not rpc for serialization: assume document');
                $payload = $return_val;
            }
        } else {
            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
        }
        $this->result = 'successful';
        if($this->wsdl){
            //if($this->debug_flag){
                $this->appendDebug($this->wsdl->getDebug());
            //  }
            if (isset($opData['output']['encodingStyle'])) {
                $encodingStyle = $opData['output']['encodingStyle'];
            } else {
                $encodingStyle = '';
            }
            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
        } else {
            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
        }
        $this->debug("Leaving serialize_return");
    }
serialize_return ( )

serializes the return value from a PHP function into a full SOAP Envelope

The following fields are set by this function (when successful)

responseSOAP

This sets the fault field on error

private

Definition at line 4018 of file nusoap.php.

References nusoap_base::appendDebug(), nusoap_base::clearDebug(), nusoap_base::debug(), elseif, fault(), nusoap_base::getDebug(), nusoap_base::getError(), nusoap_base::serialize_val(), nusoap_base::serializeEnvelope(), wsdl::serializeRPCParameters(), and nusoap_base::varDump().

                                {
        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
        // if fault
        if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
            $this->debug('got a fault object from method');
            $this->fault = $this->methodreturn;
            return;
        } elseif ($this->methodreturnisliteralxml) {
            $return_val = $this->methodreturn;
        // returned value(s)
        } else {
            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
            $this->debug('serializing return value');
            if($this->wsdl){
                if (sizeof($this->opData['output']['parts']) > 1) {
                    $this->debug('more than one output part, so use the method return unchanged');
                    $opParams = $this->methodreturn;
                } elseif (sizeof($this->opData['output']['parts']) == 1) {
                    $this->debug('exactly one output part, so wrap the method return in a simple array');
                    // TODO: verify that it is not already wrapped!
                    //foreach ($this->opData['output']['parts'] as $name => $type) {
                    //  $this->debug('wrap in element named ' . $name);
                    //}
                    $opParams = array($this->methodreturn);
                }
                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
                $this->appendDebug($this->wsdl->getDebug());
                $this->wsdl->clearDebug();
                if($errstr = $this->wsdl->getError()){
                    $this->debug('got wsdl error: '.$errstr);
                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
                    return;
                }
            } else {
                if (isset($this->methodreturn)) {
                    $return_val = $this->serialize_val($this->methodreturn, 'return');
                } else {
                    $return_val = '';
                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
                }
            }
        }
        $this->debug('return value:');
        $this->appendDebug($this->varDump($return_val));

        $this->debug('serializing response');
        if ($this->wsdl) {
            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
            if ($this->opData['style'] == 'rpc') {
                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
                if ($this->opData['output']['use'] == 'literal') {
                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
                    $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
                } else {
                    $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
                }
            } else {
                $this->debug('style is not rpc for serialization: assume document');
                $payload = $return_val;
            }
        } else {
            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
        }
        $this->result = 'successful';
        if($this->wsdl){
            //if($this->debug_flag){
                $this->appendDebug($this->wsdl->getDebug());
            //  }
            if (isset($opData['output']['encodingStyle'])) {
                $encodingStyle = $opData['output']['encodingStyle'];
            } else {
                $encodingStyle = '';
            }
            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
        } else {
            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
        }
        $this->debug("Leaving serialize_return");
    }
service ( data)

processes request and returns response

Parameters:
string$datausually is the value of $HTTP_RAW_POST_DATA public

Definition at line 3645 of file nusoap.php.

References $_SERVER, $data, nusoap_base::appendDebug(), nusoap_base::debug(), elseif, fault(), nusoap_base::getDebugAsXMLComment(), invoke_method(), parse_request(), send_response(), wsdl::serialize(), serialize_return(), nusoap_base::varDump(), and wsdl::webDescription().

                           {
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER['QUERY_STRING'])) {
            $qs = $_SERVER['QUERY_STRING'];
        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
        } else {
            $qs = '';
        }
        $this->debug("In service, query string=$qs");

        if (ereg('wsdl', $qs) ){
            $this->debug("In service, this is a request for WSDL");
            if($this->externalWSDLURL){
              if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL
                header('Location: '.$this->externalWSDLURL);
              } else { // assume file
                header("Content-Type: text/xml\r\n");
                $fp = fopen($this->externalWSDLURL, 'r');
                fpassthru($fp);
              }
            } elseif ($this->wsdl) {
                header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
                print $this->wsdl->serialize($this->debug_flag);
                if ($this->debug_flag) {
                    $this->debug('wsdl:');
                    $this->appendDebug($this->varDump($this->wsdl));
                    print $this->getDebugAsXMLComment();
                }
            } else {
                header("Content-Type: text/html; charset=ISO-8859-1\r\n");
                print "This service does not provide WSDL";
            }
        } elseif ($data == '' && $this->wsdl) {
            $this->debug("In service, there is no data, so return Web description");
            print $this->wsdl->webDescription();
        } else {
            $this->debug("In service, invoke the request");
            $this->parse_request($data);
            if (! $this->fault) {
                $this->invoke_method();
            }
            if (! $this->fault) {
                $this->serialize_return();
            }
            $this->send_response();
        }
    }
service ( data)

processes request and returns response

Parameters:
string$datausually is the value of $HTTP_RAW_POST_DATA public

Definition at line 236 of file class.soap_server.php.

References $_SERVER, $data, nusoap_base::appendDebug(), nusoap_base::debug(), elseif, fault(), nusoap_base::getDebugAsXMLComment(), invoke_method(), parse_request(), send_response(), wsdl::serialize(), serialize_return(), nusoap_base::varDump(), and wsdl::webDescription().

                           {
        global $HTTP_SERVER_VARS;

        if (isset($_SERVER['QUERY_STRING'])) {
            $qs = $_SERVER['QUERY_STRING'];
        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
        } else {
            $qs = '';
        }
        $this->debug("In service, query string=$qs");

        if (ereg('wsdl', $qs) ){
            $this->debug("In service, this is a request for WSDL");
            if($this->externalWSDLURL){
              if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL
                header('Location: '.$this->externalWSDLURL);
              } else { // assume file
                header("Content-Type: text/xml\r\n");
                $fp = fopen($this->externalWSDLURL, 'r');
                fpassthru($fp);
              }
            } elseif ($this->wsdl) {
                header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
                print $this->wsdl->serialize($this->debug_flag);
                if ($this->debug_flag) {
                    $this->debug('wsdl:');
                    $this->appendDebug($this->varDump($this->wsdl));
                    print $this->getDebugAsXMLComment();
                }
            } else {
                header("Content-Type: text/html; charset=ISO-8859-1\r\n");
                print "This service does not provide WSDL";
            }
        } elseif ($data == '' && $this->wsdl) {
            $this->debug("In service, there is no data, so return Web description");
            print $this->wsdl->webDescription();
        } else {
            $this->debug("In service, invoke the request");
            $this->parse_request($data);
            if (! $this->fault) {
                $this->invoke_method();
            }
            if (! $this->fault) {
                $this->serialize_return();
            }
            $this->send_response();
        }
    }
verify_method ( operation,
request 
)

takes the value that was created by parsing the request and compares to the method's signature, if available.

Parameters:
string$operationThe operation to be invoked
array$requestThe array of parameter values
Returns:
boolean Whether the operation was found private

Definition at line 4189 of file nusoap.php.

References elseif, and wsdl::getOperationData().

                                               {
        if(isset($this->wsdl) && is_object($this->wsdl)){
            if($this->wsdl->getOperationData($operation)){
                return true;
            }
        } elseif(isset($this->operations[$operation])){
            return true;
        }
        return false;
    }
verify_method ( operation,
request 
)

takes the value that was created by parsing the request and compares to the method's signature, if available.

Parameters:
string$operationThe operation to be invoked
array$requestThe array of parameter values
Returns:
boolean Whether the operation was found private

Definition at line 780 of file class.soap_server.php.

References elseif, and wsdl::getOperationData().

Referenced by invoke_method().

                                               {
        if(isset($this->wsdl) && is_object($this->wsdl)){
            if($this->wsdl->getOperationData($operation)){
                return true;
            }
        } elseif(isset($this->operations[$operation])){
            return true;
        }
        return false;
    }

Field Documentation

$debug_flag = false

Definition at line 163 of file class.soap_server.php.

$decode_utf8 = true

Definition at line 88 of file class.soap_server.php.

$document = ''

Definition at line 46 of file class.soap_server.php.

$externalWSDLURL = false

Definition at line 157 of file class.soap_server.php.

$fault = false

Definition at line 131 of file class.soap_server.php.

$headers = array()
$methodname = ''

Definition at line 64 of file class.soap_server.php.

Referenced by add_to_map().

$methodparams = array()

Definition at line 70 of file class.soap_server.php.

$methodreturn = false

Definition at line 119 of file class.soap_server.php.

$methodreturnisliteralxml = false

Definition at line 125 of file class.soap_server.php.

$methodURI = ''

Definition at line 58 of file class.soap_server.php.

$operations = array()

Definition at line 145 of file class.soap_server.php.

$outgoing_headers = array()

Definition at line 95 of file class.soap_server.php.

$request = ''

Definition at line 28 of file class.soap_server.php.

$requestHeader = NULL

Definition at line 40 of file class.soap_server.php.

$requestHeaders = ''

Definition at line 34 of file class.soap_server.php.

$requestSOAP = ''

Definition at line 52 of file class.soap_server.php.

$response = ''

Definition at line 101 of file class.soap_server.php.

$responseHeaders = ''

Definition at line 107 of file class.soap_server.php.

$responseSOAP = ''

Definition at line 113 of file class.soap_server.php.

$result = 'successful'

Definition at line 137 of file class.soap_server.php.

$SOAPAction = ''

Definition at line 76 of file class.soap_server.php.

$wsdl = false

Definition at line 151 of file class.soap_server.php.

Referenced by nusoap_server().

$xml_encoding = ''

Definition at line 82 of file class.soap_server.php.


The documentation for this class was generated from the following files: