For consuming a third party webservice (SOAP in my case) :
I did this by creating a new class structured like a repository. So I have an interface and a concrete class extending my base "WebService" Class (where I set up the PHP Soap class, manage the wsdl url, the login for the webservice and other common params).
Then each class has a few methods for fetching data about one aspect or another. For example, in my "UserWebService" class, I have a "getUserProfile($id)" that uses the custom methods from the webservice and does a bit of logic (for example, I like to get all results in a neat array, not an object).
Then I my controller (actually, I mainly use the webservices in Commands, from the CLI, but it's exactly the same), I inject the WebService class I need.
Then I can simply do:
$profile = $this->userWebservice->getUserProfile(Input::get($id));
Done!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community