Welcome Guest, Not a member yet? Register   Sign In
Sending WSDL file via SOAP
#3

(04-28-2015, 09:06 PM)algenza Wrote: you must load nusoap library

Ok, its working well now. but i have the example of this library.
that means will give me "Fruits   apple 4".

I have to read a DB or whatever and then send it by WSDL to a Client. im stuck in this!
Im going to write whole my code in controller & ... except the NuSoap library (because its same).

HOW can i get the data(source isnt important right now) ,  convert to WSDL and then response to the Client?

My Controller
PHP Code:
class NuSoapServer extends CI_Controller {
function 
__construct()
    {
        
parent::__construct();
        
$ns base_url();
        
$this->load->library("Nusoap_library");
        
$this->load->library("Master"); 
        
$this->server = new soap_server(); // it is a soap server object
        
$this->server->configureWSDL("SOAP"$ns); // configure wsdl
        
$this->server->wsdl->schemaTargetNamespace $ns// namespace for the server
    
}


    function 
index()
    {
        
$ns base_url();
        
$input_array = array ('count' => 'xsd:integer''type' => "xsd:string"); // method parameters
        
$return_array = array ("fruit" => "xsd:string");
        
        
//soapAction
        
$this->server->register(
            
'Master.fruits'
            
$input_array
            
$return_array
            
"urn:SOAPServerWSDL"
            
"urn:".$ns."/fruits"
            
"rpc"
            
"encoded"
            
"Fruit Types"
        
);
        
        
$this->server->service(file_get_contents("php://input")); // reading raw data 
    
}

    function 
client(){
        
$this->client = new nusoap_client(base_url()."/index.php/interface/nusoapserver?wsdl"true);

        
$this->load->view("client");
    }


My master.php in libraries folder
PHP Code:
class Master {
 public function 
fruits($count$type)
 {
 
  switch($type)
 
  {
 
   case 'red':
 
    return $count." Apple";
 
    break;
 
   case 'yellow':
 
     return $count." banana";
 
     break;
 
   }
 
 

My Client.php in view folder
PHP Code:
<?php

$error 
$this->client->getError();
if (
$error
{
 echo 
"<h2>Constructor error</h2><pre>" $error "</pre>";
}
 
 
 $result $this->client->call("Master.myfile", array("count" => 4"type" => "red"));
 
 if (
$this->client->fault
{
 
  echo "<h2>Fault</h2><pre>";
 
  print_r($result);
 
  echo "</pre>";
 
  }
 
 else {
 
   $error $this->client->getError();
 
  if ($error) {
 
   echo "<h2>Error</h2><pre>" $error "</pre>";
 
      }
 
 else {
 
   echo "<h2>Correct result</h2><pre>";
 
   echo $result;
 
   echo "</pre>";
 
  }

Reply


Messages In This Thread
Sending WSDL file via SOAP - by ardavan - 04-28-2015, 05:54 PM
RE: Sending WSDL file via SOAP - by algenza - 04-28-2015, 09:06 PM
RE: Sending WSDL file via SOAP - by ardavan - 04-28-2015, 09:33 PM
RE: Sending WSDL file via SOAP - by algenza - 04-28-2015, 11:03 PM
RE: Sending WSDL file via SOAP - by ardavan - 04-28-2015, 11:30 PM
RE: Sending WSDL file via SOAP - by algenza - 04-29-2015, 12:01 AM
RE: Sending WSDL file via SOAP - by ardavan - 04-29-2015, 12:11 AM
RE: Sending WSDL file via SOAP - by algenza - 04-28-2015, 11:46 PM
RE: Sending WSDL file via SOAP - by ardavan - 04-28-2015, 11:52 PM
RE: Sending WSDL file via SOAP - by algenza - 04-28-2015, 11:54 PM
RE: Sending WSDL file via SOAP - by ardavan - 04-28-2015, 11:59 PM
RE: Sending WSDL file via SOAP - by algenza - 04-29-2015, 12:17 AM
RE: Sending WSDL file via SOAP - by ardavan - 04-29-2015, 12:23 AM
RE: Sending WSDL file via SOAP - by algenza - 04-29-2015, 12:45 AM
RE: Sending WSDL file via SOAP - by ardavan - 05-03-2015, 05:34 PM
RE: Sending WSDL file via SOAP - by algenza - 05-05-2015, 01:36 AM
RE: Sending WSDL file via SOAP - by ardavan - 05-14-2015, 10:45 PM
RE: Sending WSDL file via SOAP - by algenza - 05-17-2015, 07:13 PM
RE: Sending WSDL file via SOAP - by ardavan - 05-20-2015, 11:53 PM
RE: Sending WSDL file via SOAP - by ardavan - 05-21-2015, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB