Welcome Guest, Not a member yet? Register   Sign In
PHP5 SoapServer and Controllers Practice
#1

[eluser]fitchwh[/eluser]
I've googled this forum and other sites but can't come up with a descent answer.

Integrating or implementing CI controllers as SoapServer classes seems to be overhead. I'm hoping this is just my lack of knowledge of CI. For example, in a standard PHP script, one might create a service like this:
Code:
<?php
class Services {
   public function someFunction() {
      // Do something here.
   }
}

$soap = new SoapServer('some.wsdl');
$soap->setClass('Services');
$soap->handle();

?>

At worst, I was hoping to add the class above to my Controller (2 separate classes), and just set the handler in the "index" method.

Code:
<?php
class Services {
   public function someFunction() {
      // Do something here.
   }
}

class MyController extends Controller {
   public function index() {
      $soap = new SoapServer('some.wsdl');
      $soap->setClass('Services');
      $soap->handle();
   }
}

?>


While this probably works, I was hoping someone out there has a more elegant way of achieving this.
#2

[eluser]fafworx[/eluser]
aloha,

in order to do mvc try this:

Code:
/**
     * default controller dispatcher
     *
     * @param void
     * @return void
     */
    public function Index()
    {
        $this->load->model('Tctrl');
        $_server    = new SoapServer(DL_WSDL);
        $_server->setClass("Tctrl");

        // look what methods there are
        var_dump($_server->getFunctions());

        $_server->handle();
    }

and all that soap class functions do in this model. that works for me.
if you dont want to have the extended methods from ci's model class in your soap class, you have to do it your old way.
#3

[eluser]fitchwh[/eluser]
There are a couple of issues with this. First, it violates the design of MVC. Models are used to interact with controllers for data access. They should not contain business logic, as that's what controllers do. Second, you are essentially doing the same thing I did. You loaded a class (a model in this case) which requires the same effort. One could have easily loaded a library, helper, or just included any class. You are missing the point.

Ideally, their should be a SOAPController as a substitute for Controller that handles the child requests. It should auto-generate the WSDL, allow customization of complex types, etc.
#4

[eluser]wiredesignz[/eluser]
[quote author="fitchwh" date="1223319757"]Models are used to interact with controllers for data access. They should not contain business logic, as that's what controllers do. [/quote]

Sadly you are mistaken:
[quote author="wikipedia" date="1223319757"]In MVC, the model represents the information (the data) of the application and the business rules used to manipulate the data.

The controller processes and responds to events, typically user actions, and may invoke changes on the model.[/quote]

http://en.wikipedia.org/wiki/Model-view-controller

Good luck.
#5

[eluser]fitchwh[/eluser]
The controller is responsible for action calls between the client and model. The business rules behind the information is handled by the model (what table or view, joins, etc.), and initiated by the controller; this type of model is known as a passive model, due to the limitations of the web (request/response cycles).

The reason I specifically wanted a SOAP controller is to handle the interactions between the SOAP client and server. The model can then be executed to interact with the business rules in relation to data, not action.

Since we are on the topic of MVC philosophy, your documentation states:

Quote:The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.

While this is the case in CodeIgniter, it is not correct for MVC.

Quote:The controller is NOT a Mediator between the view and the model. The controller does not sit in between the model and the view. Both the controller and the view have equal opportunity to access the model.

Your documentation should make this more obvious.
#6

[eluser]wiredesignz[/eluser]
[quote author="fitchwh" date="1223344987"]

Your documentation states:

Quote:The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.
.[/quote]

You are quite correct my documentation should not state this. :lol:




Theme © iAndrew 2016 - Forum software by © MyBB