CodeIgniter Forums
Help with NuSoap CodeIgniter Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Help with NuSoap CodeIgniter Library (/showthread.php?tid=12911)



Help with NuSoap CodeIgniter Library - El Forum - 11-04-2008

[eluser]CARP[/eluser]
Hi guys
I've downloaded NuSoap CodeIgniter library from
http://codeigniter.com/wiki/CI_Nusoap_Library/

One of my problems is that I have not found any little simple example for creating a service, creating a client, setting a wsdl (or whatever is called), etc.

And the main problem is that I'm doing a webApp in CI that needs to publish/share data (automatically) with other websites, and of course I think nuSoap/CI will be the best solution... right ?

Hope someone can provide some simple controllers for service/client so every newbie that looks for this had a good starting point for learning

Thanks again,


Help with NuSoap CodeIgniter Library - El Forum - 11-14-2008

[eluser]CARP[/eluser]
Hi guys
Sorry for bumping, but I give up.
As wrote before, I've got latest CI_Nusoap_Library, and here are my controllers (which I built getting examples from these forums)...

webservice.php controller
Code:
<?php

class webservice extends Controller {

    function webservice() {
        parent::Controller();
        ini_set("soap.wsdl_cache_enabled", "0");
        $this->load->library("Nusoap");
    }

    function wsdl() {
        if($this->uri->segment(2) == "wsdl") {
            $_SERVER['QUERY_STRING'] = "wsdl";
        } else {
            $_SERVER['QUERY_STRING'] = "";
        }
        $rawPost = strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0? (isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input")) : NULL;
        $server = new soap_server;
        $server->configureWSDL("localhost");
        $server->register("hello");
        $server->service($rawPost);        
    }
    
    function index() {
    }

    function hello() {
        function hello($name) {
            $CI =&get;_instance();
            return 'Hi '.$name;
        }
    }    
    
}

webserviceclient.php controller
Code:
<?php

class webserviceclient extends Controller {

    function webserviceclient() {
        parent::Controller();
        ini_set("soap.wsdl_cache_enabled", "0");
        $this->load->library("Nusoap");
    }
    
    function index() {
        $serviceurl = $this->config->item('base_url')."/index.php/webservice/wsdl";
        $soapclient = new soapclient($serviceurl);
        echo $soapclient->call( 'hello' , array('name' => 'World') );
    }

}

I call:
http://localhost/testsite/index.php/webservice/wsdl
shows the XML dump correctly

I call:
http://localhost/testsite/index.php/webserviceclient
and shows the following error

http://img255.imageshack.us/img255/5646/captura10bx0.jpg


Help with NuSoap CodeIgniter Library - El Forum - 11-14-2008

[eluser]Chris Newton[/eluser]
Unless "hello" is your SOAP server URL or path, shouldn't you be doing something like this:

Code:
function index() {
        $serviceurl = $this->config->item('base_url')."/index.php/webservice/wsdl";
        $soapclient = new soapclient($serviceurl,TRUE);
        echo $soapclient->call( $serviceurl , array('name' => 'World') );
    }

I didn't dig too deep, but it looks like the nusoap library is trying access a named index that doesn't exist... the reason it probably doesn't exist is that you don't have a valid response.

Re: your private message. I didn't write that library, I just made a note in the wiki.


Help with NuSoap CodeIgniter Library - El Forum - 11-14-2008

[eluser]CARP[/eluser]
Hi mahuti
I've tried your suggestion: I get a blank page

And, I've tried this
http://ellislab.com/forums/viewreply/394237/

and also get a blank page

I personally suspect about the function the service wants to register. I don't know up to which point CI will execute that function when the controller client calls it... I've "debugged" it with simple echos and die()'s and it is never called

Code:
function hello() {
        function hello($name) {
            $CI =&get;_instance();
            return 'Hi '.$name;
        }
    }



Help with NuSoap CodeIgniter Library - El Forum - 11-15-2008

[eluser]Chris Newton[/eluser]
I thought your get_instance was wrong, but it looks like the forum just auto-changed the display of it.

Anyway, based on the code above... wouldn't your service call just call the containing hello() function. It's not declared as a class or anything, so the hello() function inside it wouldn't be a constructor.

Anyway, I doubt I can be of much use on this. I never used that nusoap library. Turns out I didn't need it, I just used curl for my purposes once, xml for another time, and xml-rpc for another.


Help with NuSoap CodeIgniter Library - El Forum - 11-16-2008

[eluser]CARP[/eluser]
ok. No prob.
Hope someone else can help me to correct this issue. I'm still stuck


Help with NuSoap CodeIgniter Library - El Forum - 03-26-2009

[eluser]Nathan Pitman (Nine Four)[/eluser]
Hi CARP, did you find a solution to this problem?


Help with NuSoap CodeIgniter Library - El Forum - 03-26-2009

[eluser]CARP[/eluser]
Hi Nathan
I gave up then. I was with a little rush
So, instead of using CI nusoap library, I did a standalone WS, standalone client, and I call each one from CI


Help with NuSoap CodeIgniter Library - El Forum - 03-27-2009

[eluser]Nathan Pitman (Nine Four)[/eluser]
Yea, that's the route I ended up taking a year back but I was hoping to make it work this time round as the integration with CI is so beneficial... generating emails as a result of a web service call for example... being able to parse a email template blah blah blah... Smile