I have a web service developed with webdev, and I want to consume it with Symfony 2.
At this time, I went for pure PHP. I tried to define objects as classes like they are described in the wsdl (which will allow me to create instances of the object directly). Exemple :
class my_complex_type{
public $my_basic_type1 = null ;
public $my_basic_type2 = null ;
public $my_basic_type3 = null ;
public function __construct($my_basic_type1, $my_basic_type2, $my_basic_type3){
$this->my_basic_type1 = $my_basic_type1 ;
$this->my_basic_type1 = $my_basic_type1 ;
$this->my_basic_type1 = $my_basic_type1 ;
}
// setters and getters ...
}
and call functions with :
public function my_function(my_type $parameters)
{
return $this->__soapCall('my_function', array($parameters));
}
The problem I encounter with this method is that I think that this doesn't make the code as flexible as it should be and it's pretty annoying to re-code things that are already written in the wsdl.
So I wonder if you have any option that could be more handy (and maybe more Symfony-friendly)
editor's note: English isn't my native language so please don't blame me, I tried my best to make this topic intelligible
I will be grateful for any help you can provide.
Anytime you need to use a class more then once across your application you need to define it as a service. A service is a php object that performs some type of global task. One cool thing about services, are the fact that you can inject other services into them using a process called Injection. I know you are worried about having your code flexible. I promise that this type of injection offers an extreme amount of flexibility. If you find that this is not flexible enough for you, then symfony has something called a factory which offers even more flexibility. Check it out....http://symfony.com/doc/current/components/dependency_injection/factories.html