I've decided to include versions 1 and 2 of Web Service definition using SOAP and RESTful protocols in SugarOnDrupal module. This would definitively improve the level of integration with existing Drupal or SugarCRM life applications. The same API call answer different results in V1 and V2 methods, and the format type could be different using RESTful or SOAP protocols, but this is not important, it can be handled programatically. The bad part is (what is this blog post about): what are the technological requirements to do so?
Let's begin with Drupal requirements:
About RESTful client, as (for now) it's going to be built internally for SugarOnDrupal module, these would be the requirements:
The transport part is a little bit more complicated, because it may be based in libCURL:
Now, about SOAP interface.. This is quite complicated..
According to SugarCRM wiki, internally on the server side, the SOAP interface is implemented with nuSoap, a PHP SOAP library. In fact, they recommend to use nuSOAP because other implementation may have issues as complaining with SOAP protocols, including PHP5 SOAP. In any case, lets develop this a little bit:
The bad part is about what SOAP interface can web use.. PHP SOAP or nuSOAP. SugarCRM recommends nuSOAP because PHP5 SOAP doesn't complain well with WSDL request types, but this could be fixed using non-wsdl mode.
I should also consider that PHP json interface may behaviour differently in each PHP version..
The last part: SugarCRM Version (because of the supported protocols)
Ok, now we know more or less the requirements for each interface.
Conclusions?
To make things easier for the module user, I'm refusing the idea of having to install other dependencies (e.g. nuSOAP). Having nuSOAP as recommended interface for SugarCRM webservices, I've to consider that it may get into conflict if PHP5 SOAP is enabled, because both uses the same class function names, therefore nuSOAP should have to be modified to work with PHP5 SOAP enabled in the PHP side. I'm not sure how could this be avoided with a PHP 4 version, because it has no any kind of soap interaction. Should the user install nuSOAP as a requirement?
The last idea comming to my mind is about writting a simple to_soap() funciton able to build the queries that SugarCRM nuSOAP server would expect, as the WebServices part will be static enough to not need adaptability or changes.. I don't know..