0

This is my controller.

    class Cteam extends MY_Controller {      
    //This is my server    
    public function server(){
            if($this->uri->rsegment(3) == "wsdl") {
                $_SERVER['QUERY_STRING'] = "wsdl";
            } else {
                $_SERVER['QUERY_STRING'] = "";
            }

            //$ns= site_url()."cteam/cteam/server/wsdl";
            $ns= site_url()."cteam/cteam/wsdl";
            $endpoint = site_url()."cteam/cteam/server/wsdl";

            $this->load->library("Nusoap_library"); //load the library here
            $this->load->library('xmlrpc');
            $this->nusoap_server = new soap_server();

            $this->nusoap_server->configureWSDL('sever','urn:'.$ns,$endpoint);

            $this->nusoap_server->wsdl->schemaTargetNamespace='urn:'.$ns;

            $input_array = array ('count' => 'xsd:integer', 'type' => "xsd:string"); // method parameters
            $return_array = array ("fruit" => "xsd:string");

            $this->nusoap_server->register(
                'fruits', 
                $input_array, 
                $return_array, 
                "urn:SOAPServerWSDL", 
                "urn:".$ns."/fruits", 
                "rpc", 
                "encoded", 
                "Fruit Types"
            );

            function fruits($count,$type){
                switch($type){
                case 'red':
                    return $count." Apple";
                    break;
                case 'yellow':
                    return $count." banana";
                    break;                
                }
            }

            $this->nusoap_server->service(file_get_contents("php://input"));
        }

//This is my client
function test_soap2(){
       $this->load->library("Nusoap_library");
       $n_params = array("count" => 4, "type" => "red");

       $this->nusoap_client = new nusoap_client('http://localhost/desimd/cteam/cteam/wsdl/',array('soap_version' => SOAP_1_1));
       $this->nusoap_client->soap_defencoding = 'UTF-8';

       $err = $this->nusoap_client->getError();
       if ($err){
           echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
       }

       $result = $this->nusoap_client->call('fruits', array('parameters' => $n_params));
       echo $result;

       // Check for a fault
       if ($this->nusoap_client->fault) {
           echo '<h2>Fault</h2><pre>';
           print_r($result1);
           echo '</pre>';
       } else {
           // Check for errors
           $err = $this->nusoap_client->getError();
           if ($err) {
               // Display the error
               echo '<h2>Error</h2><pre>' . $err . '</pre>';
           } else {
               // Display the result
               echo '<h2>Result</h2><pre>';
               print_r($result1);
           echo '</pre>';
           }
       }

    }

    }

Controller is located in controller/cteam/ folder. This is my router:

$route['cteam/cteam/wsdl'] = 'cteam/cteam/server/wsdl';

When I call server: http://localhost/desimd/cteam/cteam/wsdl/ I am getting the xml.

When I call client: http://localhost/desimd/cteam/cteam/test_soap2/ It is giving me error: wsdl error: XML error parsing WSDL.... Mismatched tag

Can anybody help me?

chandoo
  • 1,276
  • 2
  • 21
  • 32
  • 1
    http://stackoverflow.com/questions/945922/nusoap-how-to-change-content-type-of-request meh? – qwertzman Jan 28 '16 at 10:52
  • When I added I am getting new error. wsdl error: XML error parsing WSDL Mismatched tag – chandoo Jan 28 '16 at 11:03
  • 1
    Possible duplicate of [nusoap XML error parsing WSDL](http://stackoverflow.com/questions/9434394/nusoap-xml-error-parsing-wsdl) – bviale Jan 28 '16 at 11:16
  • 1
    It's not a duplicate, call() is being used correctly. This could best be tested with SoapUI and checking server logs. – qwertzman Jan 28 '16 at 11:20
  • Dear bviale, You made this question duplicate and still didn't found answer. Anyway, appreciate if you gave any solution rather than make it duplicate. – chandoo Jan 28 '16 at 15:26

0 Answers0