CodeIgniter Forums
Getting NuSoap working with CI without Querystrings - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Getting NuSoap working with CI without Querystrings (/thread-6101.html)



Getting NuSoap working with CI without Querystrings - El Forum - 02-14-2008

[eluser]Nathan Pitman (Nine Four)[/eluser]
So I've installed the NuSoap Library from the Wiki (http://codeigniter.com/wiki/CI_Nusoap_Library/) and it seems to work (kinda) but perhaps becuase I'm using segments and not querystrings for my app I've run into problems.

If I query the web services page to display the wsdl it returns a 404, I guess becuase of the '?' in the URL. I've tried adding a rule to routes.php to overcome this but no luck...

Code:
$route['web_services/:any'] = "web_services";

Any ideas? It's so close to working yet so far! I've included my controller code below:

Code:
<?php

class Web_services extends Controller {

    function Web_services()
    {
        parent::Controller();
        $this->load->library('nusoap');
        $this->load->model('result');
    }
    
    function index()
    {            
        
        $namespace = "http://www.mydomainname.co.uk/web_services";
        $server = new soap_server();
        $server->debug_flag = false;
        $server->configureWSDL("CompanyName - WSDL", $namespace);
        $server->wsdl->schemaTargetNamespace = $namespace;
            
        // Single Result Type
        $server->wsdl->addComplexType(
          'Result',
          'complexType',
          'struct',
          'all',
          '',
          array(
            'ResultId' => array('name' => 'ResultId',
                 'type' => 'xsd:int'),
            'ResultEmail' => array('name' => 'ResultEmail',
                 'type' => 'xsd:string'),
            'ResultFirstname' => array('name' => 'ResultFirstname',
                'type' => 'xsd:string'),
            'ResultSurname' => array('name' => 'ResultSurname',
                'type' => 'xsd:string')
          )
        );
        
        $server->register('GetResult',                                // method name
          array('UserEmail' => 'xsd:string','ProductRef' => 'xsd:string','ClientId' => 'xsd:int'), // input parameters
          array('return' => 'tns:Result'),                            // output parameters
          $namespace,                                                // namespace
          $namespace . '#GetResult',                                // soapaction
          'rpc',                                                    // style
          'encoded',                                                // use
          'Get a users results'        // documentation
        );
        
        
        // Get a specific users result for a specific product
        function GetResult($email, $product_ref='FW', $client_id)
        {
          $query = $this->result->get_ws_result($email, $product_ref, $client_id);
          
          return array(
            "ResultId" => $query->id,
            "ResultEmail" => $query->email,
            "ResultFirstname" => $query->firstname,
            "ResultSurname" => $query->surname
          );
        }
        
        // Output        
        $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
          ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
        $server->service($HTTP_RAW_POST_DATA);
        exit();
    }
    
}
?>



Getting NuSoap working with CI without Querystrings - El Forum - 02-29-2008

[eluser]jeffpeck[/eluser]
You could try:

$_SERVER['QUERY_STRING'] = "wsdl";

to force it to think that it's a always a request....


Getting NuSoap working with CI without Querystrings - El Forum - 03-01-2008

[eluser]Nathan Pitman (Nine Four)[/eluser]
Thanks for the tip, I might give that a shot next time. I ended up using the 'ActiveRecordFactory' library, an extracted version of the CI AR library in the end. It meant I had to re-write a bunch of code but it worked! Smile

http://ellislab.com/forums/viewthread/72375/