Welcome Guest, Not a member yet? Register   Sign In
Getting NuSoap working with CI without Querystrings

[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...

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

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


class Web_services extends Controller {

    function Web_services()
    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
            '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        
          ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

You could try:

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

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

[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


Theme © iAndrew 2016 - Forum software by © MyBB