CodeIgniter Forums
Easy way to use nusoap with CI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Easy way to use nusoap with CI (/showthread.php?tid=18820)



Easy way to use nusoap with CI - El Forum - 05-19-2009

[eluser]Unknown[/eluser]
So, I had to make soap server in CI and it wasn't easy for me, but at last i did it Smile.
I couldn't find any easy ways to do this on this forum so I decided to share my experience.

first of all you should download the attached zip and unpack it in your libraries folder. there is nusoap directory and nusoap_lib.php.

second step: create controller for example soap_member.php and paste this code in it:

Code:
class Soap_Member extends Controller {
    
    var $nusoap_server;
    var $ns = "http://localhost/index.php/soap_member/"; //this is namespace
    
    function Soap_Member()
    {
        parent::Controller();
        
        $this->load->library("Nusoap_lib");
        $this->nusoap_server = new soap_server();
        $this->nusoap_server->configureWSDL("MemberWSDL", $this->ns);
        $this->nusoap_server->wsdl->ports = array('MemberWSDLPort'=> array(
                                                                              "binding"  => "MemberWSDLBinding",
                                                                              "location" => $this->ns,
                                                                              "bindingType"=> "http://schemas.xmlsoap.org/wsdl/soap/"
                                                                              ));
        
        $this->nusoap_server->register(
            "getMember",
            array('member_id' => 'xsd:integer'),
            array("return"=>"xsd:string"),
            "urn:MemberWSDL",
            "urn:".$this->ns."/getMember",
            "rpc",
            "encoded",
            "Get Member"
        );

        function getMember($member_id) {
            $CI =& get_instance();
            //you can access any of your models like this $CI->member_model->function_name();
            return 'Member';
        }
    }
    
    function index()
    {
        $this->nusoap_server->service(file_get_contents("php://input"));    
    }
    function webservice()
    {
        if($this->uri->rsegment(3) == "wsdl") {
                $_SERVER['QUERY_STRING'] = "wsdl";
            } else {
                $_SERVER['QUERY_STRING'] = "";
            }
        $this->nusoap_server->service(file_get_contents("php://input"));    
    }
}

now you can see your wsdl on the same link in your $ns and test your soap server from here or from any soap client.


Easy way to use nusoap with CI - El Forum - 07-15-2009

[eluser]ken.sniper[/eluser]
Could you show the clinet code of this soap_server.thank you very much.


Easy way to use nusoap with CI - El Forum - 03-12-2010

[eluser]ortenheim[/eluser]
thank god for a soap library that works!

can you make a simple soap client example of connecting to an external soap server with xml parsing?

best regards,

Mikael