CodeIgniter Forums
problem with webservice inside CI - 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: problem with webservice inside CI (/thread-11190.html)



problem with webservice inside CI - El Forum - 08-29-2008

[eluser]Kurtis[/eluser]
I would like some help with the fallowing!
it's a simple hello world example that's work outside CI, but when I tried putting in it a controller it just wont work, maybe someone can guide me in the right direction.
here's what I have outside:
/* services.php */
Code:
require_once('../nusoap/lib/nusoap.php');

  $server = new soap_server();

  $server->configureWSDL('services', 'urn:helloString');

  $server->register("getHello",
                       array('fname' => 'xsd:string'),
                       array('return' => 'xsd:string'),
                       'urn:helloString',
                       'urn:services#getHello'
                       );

   $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
   $server->service($HTTP_RAW_POST_DATA);


function getHello($fname) {
         $response = "Hello  ".$fname;
      return $response;
  }
In both cases, the client is inside CI (webclient.php)
Code:
class Webclient extends Controller {

    function Webclient() {
        parent::Controller();
        $this->load->library("nusoap");
    }

    function index()
     {

           $fname = "john doe";
           //$wsdlurl = 'http://localhost/services/index/wsdl'; //inside CI
           $wsdlurl = 'http://localhost/services.php?wsdl'; //outside CI
        $client = new soapClient($wsdlurl,true);
        $result = $client->call('getHello', array('fname' => $fname));
        print "$result";
      }
  }
here's what I tried inside CI, but I think it just never call the function getHello, I got null as a response.
services.php:
Code:
class Services extends Controller {

    function Services() {
        parent::Controller();
        $this->load->library("nusoap");
    }

    function index()
     {

             $_SERVER['QUERY_STRING'] = 'wsdl';
          $server = new soap_server();
          $server->configureWSDL('services', 'urn:idhello');
          $server->register("getHello",
                               array('fname' => 'xsd:string'),
                               array('return' => 'xsd:string'),
                               'urn:idhello',
                               'urn:services#getHello'
                               );
           $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
           $server->service($HTTP_RAW_POST_DATA);
      }

     function getHello($fname) {
              $response = "Hello  ".$fname;
              return $response;
      }
}

thank in advance for any suggestion to make it work Smile


problem with webservice inside CI - El Forum - 03-27-2009

[eluser]Nathan Pitman (Nine Four)[/eluser]
Hi Kurtis, apparently I am stalking you on the forums! Smile

Again would love to see the final code if you got this working, I'm having the exact same problem as you described here.