QuickBooks/SOAP/Server.php
public function handle($raw_http_input)
	{
		// Determine the method, call the correct handler function 
		
		$builtin = QuickBooks_XML::PARSER_BUILTIN;		// The SimpleXML parser has a difference namespace behavior, so force this to use the builtin parser
		$Parser = new QuickBooks_XML_Parser($raw_http_input, $builtin);
		
		$errnum = 0;
		$errmsg = '';
		if ($Doc = $Parser->parse($errnum, $errmsg))
		{
			//print('parsing...');
			
			$Root = $Doc->getRoot();
			
			$Body = $Root->getChildAt('SOAP-ENV:Envelope SOAP-ENV:Body');
			if (!$Body)
			{
				$Body = $Root->getChildAt('soap:Envelope soap:Body');
			}
			
			$Container = $Body->getChild(0);
			
			$Request = null;
			$method = '';
			if ($Container)
			{
				$namespace = '';
				$method = $this->_namespace($Container->name(), $namespace);
				$Request = $this->_requestFactory($method);
				
				foreach ($Container->children() as $Child)
				{
					$namespace = '';
					$member = $this->_namespace($Child->name(), $namespace);
					
					//$Request->$member = html_entity_decode($Child->data(), ENT_QUOTES);
					$Request->$member = $Child->data();
				}
			}
			
			//print('method is: ' . $method . "\n");
			
			$Response = null;
			if (method_exists($this->_class, $method))
			{
				$Response = $this->_class->$method($Request);
			}
			
			$soap = '<?xml version="1.0" encoding="UTF-8"?>
			<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
			 xmlns:ns1="http://developer.intuit.com/">
				<SOAP-ENV:Body><ns1:' . $method . 'Response>';
			
			$vars = get_object_vars($Response);
			
			$soap .= $this->_serialize($vars);
			
			$soap .= '</ns1:' . $method . 'Response>
			</SOAP-ENV:Body>
			</SOAP-ENV:Envelope>';
			
			print($soap);
			return true;
		}
		else
		{
			$soap = '';
			$soap .= '<?xml version="1.0" encoding="UTF-8"?>' . QUICKBOOKS_CRLF;
			$soap .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' . QUICKBOOKS_CRLF;
			$soap .= '	<SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
			$soap .= '		<SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
			$soap .= '			<faultcode>SOAP-ENV:Client</faultcode>' . QUICKBOOKS_CRLF;
			$soap .= '			<faultstring>Bad Request: ' . htmlspecialchars($errnum) . ': ' . htmlspecialchars($errmsg) . '</faultstring>' . QUICKBOOKS_CRLF;
			$soap .= '		</SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
			$soap .= '	</SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
			$soap .= '</SOAP-ENV:Envelope>' . QUICKBOOKS_CRLF;
			
			print($soap);
			return false;
		}
	}
public function handle($raw_http_input)
	{
		// Determine the method, call the correct handler function 
		
		$builtin = QuickBooks_XML::PARSER_BUILTIN;		// The SimpleXML parser has a difference namespace behavior, so force this to use the builtin parser
		$Parser = new QuickBooks_XML_Parser($raw_http_input, $builtin);
		
		$errnum = 0;
		$errmsg = '';
		if ($Doc = $Parser->parse($errnum, $errmsg))
		{
			//print('parsing...');
			
			$Root = $Doc->getRoot();
			
			$Body = $Root->getChildAt('SOAP-ENV:Envelope SOAP-ENV:Body');
			if (!$Body)
			{
				$Body = $Root->getChildAt('soap:Envelope soap:Body');
			}
			
			$Container = $Body->getChild(0);
			
			$Request = null;
			$method = '';
			if ($Container)
			{
				$namespace = '';
				$method = $this->_namespace($Container->name(), $namespace);
				$Request = $this->_requestFactory($method);
				
				foreach ($Container->children() as $Child)
				{
					$namespace = '';
					$member = $this->_namespace($Child->name(), $namespace);
					
					//$Request->$member = html_entity_decode($Child->data(), ENT_QUOTES);
					$Request->$member = $Child->data();
				}
			}
			
			//print('method is: ' . $method . "\n");
			
			$Response = null;
			if (method_exists($this->_class, $method))
			{
				$Response = $this->_class->$method($Request);
			}
			
			$soap = '<?xml version="1.0" encoding="UTF-8"?>
			<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
			 xmlns:ns1="http://developer.intuit.com/">
				<SOAP-ENV:Body><ns1:' . $method . 'Response>';
			
			$vars = get_object_vars($Response);
			
			$soap .= $this->_serialize($vars);
			
			$soap .= '</ns1:' . $method . 'Response>
			</SOAP-ENV:Body>
			</SOAP-ENV:Envelope>';
			
			print($soap);
			return true;
		}
		else
		{
			$soap = '';
			$soap .= '<?xml version="1.0" encoding="UTF-8"?>' . QUICKBOOKS_CRLF;
			$soap .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' . QUICKBOOKS_CRLF;
			$soap .= '	<SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
			$soap .= '		<SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
			$soap .= '			<faultcode>SOAP-ENV:Client</faultcode>' . QUICKBOOKS_CRLF;
			$soap .= '			<faultstring>Bad Request: ' . htmlspecialchars($errnum) . ': ' . htmlspecialchars($errmsg) . '</faultstring>' . QUICKBOOKS_CRLF;
			$soap .= '		</SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
			$soap .= '	</SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
			$soap .= '</SOAP-ENV:Envelope>' . QUICKBOOKS_CRLF;
			
			print($soap);
			return false;
		}
	}
Handle a SOAP request

@param string $raw_http_input		The raw incoming SOAP request (HTTP request body)
@return boolean