Re: Best place for a SoapClient?
For web services, I end up creating a Lib/*WebService.php and appropriate class name.
Each *WebService class represents an end point.
Each method in the *WebService class represents an actual web service call. Some calls are simple, and I can take the parameters from the argument list. Some are a bit more complicated, and I'll write the request to the database first, then pass an id of that request. You could also pass a data structure as well. Each call will return false, or the actual Response from a successful call.
Each *WebService file also contains class definitions for the complex types required by that end point. It's a bit simplistic, and assumes no conflicts between WebService classes, or only one WebService gets used per HTTP request. Proper support for namespaces could reduce this, or a file per complex type, and usage of App::uses().
Each *WebService class extends a common *GatewayWebService class the provides common services like authentication, setting up end point locations, etc. This is for when one vendor supplies multiple end points that share an authentication scheme, and/or credentials. It also provides unified error processing, and calls the SoapClient.
In my case, I actually have an SSLSoapClient that extends the regular SoapClient. This will opt to use CURL if the URL or endpoint is SSL, by overriding the __construct() and __doRequest(). That's usually because the WSDL is also behind the SSL web service, and PHP SoapClient doesn't send client certificate info when trying to get a WSDL behind an SSL end point that requires a certificate.
When it comes to usage, my controllers end up calling the *WebService methods, as needed.
I've previously tried to make use of model and custom datasources, but datasources are not at a point where you can use it for non RDBMS sources without jumping through a whole bunch of hoops. If CakePHP ever introduces an extensible class that takes care of all SoapClient usage, complete with SSL options, then I'll gladly use it, but for now, it's easier to roll my own.
On Tuesday, 14 May 2013 15:10:02 UTC+10, LDSign wrote:
-- I've previously tried to make use of model and custom datasources, but datasources are not at a point where you can use it for non RDBMS sources without jumping through a whole bunch of hoops. If CakePHP ever introduces an extensible class that takes care of all SoapClient usage, complete with SSL options, then I'll gladly use it, but for now, it's easier to roll my own.
On Tuesday, 14 May 2013 15:10:02 UTC+10, LDSign wrote:
HiI am trying to include a really complex php5 SoapClient interface with tons of objects and methods in my cake app. What do you think is the best place for the code? Controller, component, model or a DBSource?The code must not be reusable, because its very specific.Thank you for pushing me into the right direction,Frank
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home