Welcome Guest, Not a member yet? Register   Sign In
problem with webservice inside CI
#1

[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
#2

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




Theme © iAndrew 2016 - Forum software by © MyBB