<?php
  class Tickets_Serv extends Controller
  {
  	public $server;
	public $namespace;

  	function Tickets_Serv()
	{
		parent::Controller();	
		$this->load->helper(array('url'));
		require_once('files/nusoap/nusoap.php');
		$ini = ini_set("soap.wsdl_cache_enabled", 0);
		
		$this->namespace = base_url().'index.php/tickets_serv/';
		
		$this->server = new soap_server;
		$this->server->configureWSDL('tickets_serv_WSDL', $this->namespace);
		$this->server->wsdl->ports = array('TicketsWSDLPort'=> array(
			"binding" => "TicketsWSDLBinding",
			"location" => $this->namespace,
			"bindingType"=> "http://schemas.xmlsoap.org/wsdl/soap/"
			));		
		$this->server->wsdl->schemaTargetNamespace = $this->namespace;
		$this->server->soap_defencoding = 'UTF-8';
		$this->server->decode_utf8 = false;
		
		$this->server->register(
			'hello_world',
			array('name'=>'xsd:string'),
			array('return'=>'xsd:string'),
			$this->namespace);			

		function hello_world($name)
		{
			return 'Hello '.$name;
		}			

	}
	function index()
	{

		/*
        if($this->uri->segment(3) == "wsdl") {
            $_SERVER['QUERY_STRING'] = "wsdl";
        } else {
            $_SERVER['QUERY_STRING'] = "";
        }		
		
		// Use the request to (try to) invoke the service
		$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
		$this->server->service($HTTP_RAW_POST_DATA);	
		*/
		$this->server->service(file_get_contents("php://input"));
	}
	function webservice()
	{
		if($this->uri->rsegment(3) == "wsdl") {
			$_SERVER['QUERY_STRING'] = "wsdl";
		} else {
			$_SERVER['QUERY_STRING'] = "";
		}
		$this->server->service(file_get_contents("php://input"));
	}	
}	
?>