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?