Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP Server with CodeIgniter
    primarykey
    data
    text
    <p>I'm extending a webapp written with CI to communicate with visual basic application.</p> <p>First of all i'd like to know if the solution i've choosen is a good option... i previously worked whith xml-rpc and put hands in a REST service, but to me SOAP solutions look more complete. Am i wrong?</p> <p>Anyway, the problem up to now is that i cant call function inside my controller... here's my code:</p> <pre><code>class Webservice extends CI_Controller { function __construct() { parent::__construct(); } public function index() { $server = new SoapServer("http://www.site.com/test.wsdl"); $server-&gt;setObject($this); //$server-&gt;addFunction('sayHello'); $server-&gt;handle(); } function sayHello($name) { $salute = "Hi " . $name . ", it's working!"; return $salute; } } </code></pre> <p>I've compiled the wsdl file, but after i call site.com/webservice i get the following error:</p> <p><em>SoapServer::addFunction() [soapserver.addfunction]: Tried to add a non existant function 'sayHello'</em></p> <p>I've also tried passing $CI=&amp; get_instance() to $server->setObject(), but i think its the same as passing $this.</p> <p><strong>UPDATE - 12/09/2011</strong></p> <p>I figured it out... there is no need to use addFunction() if is already set the entire object $this. SOAP will call only the functions declared in the wsdl file, anyway it seems that i could not set a function as privete/protected.</p> <p>Having said that I'm not sure to go ahead with SOAP... the <a href="http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/" rel="nofollow">tutorial written by Phil Sturgeon</a> show a good solution using REST approach that return different response types (json, xml, serialize, csv).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload