Welcome Guest, Not a member yet? Register   Sign In
CI SOAP Server Problem
#9

[eluser]JanDoToDo[/eluser]
i.e. The basic format is, with all my code stripped out

Code:
class Server extends Controller {

    function __construct()
    {
        parent::__construct();
        function get_function1($parameters)
        {
            // Perform actions with $parameters (its an object an so is referenced with $parameters -> item name)
            // If you are doing database interaction (which presumably you WILL be) it doesn't seem to be possible to use the CI db class as it causes
            // the soap server to fail. As such use mysql_connect                    
            $conn = mysql_connect('localhost', $dbuser, $dbpass) or die ('Error connecting to mysql');
            mysql_select_db($dbname);
            
            // Perform functions and set soap faults
            if (xxx condition) {
                // Do all the database work
                $sql = 'SELECT * FROM tablename';
                if ($order_query = mysql_query($sql)) :
                    while ($order_row = mysql_fetch_array($order_query)) :
                        // Get all the data you want
                    endwhile;
                endif;
                // Send back the data as an array as specified in the WSDL
                return $data
            } else {
                throw new SoapFault("Server", "XXX condition not satisfied");
            }
        }
        
        function get_function2($parameters)
        {
            // Perform actions for function 2
        }
    }
    
    function index()
    {
        // Make sure the wsdl file is not cached by the user
        ini_set('soap.wsdl_cache_limit', 0);
        ini_set('soap.wsdl_cache_ttl', 0);
        
        $server = new SoapServer(url-path-to-wsdl-file);
        // Add each of the function you want
        $server -> addFunction('get_function1');
        $server -> addFunction('get_function2');
        // Serve
        $server -> handle();
    }
}


Messages In This Thread
CI SOAP Server Problem - by El Forum - 03-19-2010, 05:49 AM
CI SOAP Server Problem - by El Forum - 03-19-2010, 06:24 AM
CI SOAP Server Problem - by El Forum - 03-19-2010, 06:25 AM
CI SOAP Server Problem - by El Forum - 03-19-2010, 06:26 AM
CI SOAP Server Problem - by El Forum - 03-19-2010, 06:31 AM
CI SOAP Server Problem - by El Forum - 03-19-2010, 07:16 AM
CI SOAP Server Problem - by El Forum - 03-21-2010, 04:27 PM
CI SOAP Server Problem - by El Forum - 03-29-2010, 12:14 PM
CI SOAP Server Problem - by El Forum - 03-29-2010, 12:21 PM
CI SOAP Server Problem - by El Forum - 06-09-2010, 12:32 PM
CI SOAP Server Problem - by El Forum - 06-09-2010, 12:42 PM
CI SOAP Server Problem - by El Forum - 06-09-2010, 01:06 PM
CI SOAP Server Problem - by El Forum - 06-09-2010, 01:19 PM
CI SOAP Server Problem - by El Forum - 06-09-2010, 02:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB