Support the ongoing development of Laravel.io →
Configuration Requests
Last updated 1 year ago.
0

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!

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

marcialjv marcialjv Joined 15 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.