We need to create new records in a remote system based upon new Drupal entities, via a SOAP service provided by the remote system. Rather than building a query of the Drupal entities/fields in a module, I thought it would be cleaner to use views to build the query and pass this data to WSclient to build the SOAP "create " call. Any suggestions as to whether this is possible/a good idea, or where to start? If not we will just make do with a combination of Google and niaeve optimism ;D

Comments

dman’s picture

Well, views is for extracting info from your local data,
and a web service create is for writing to a remote one.

It's not too hard to see some glue that would sit between them - but that glue would be your own, and would act as the mediator that uses views to read, sorts out what to do with that, and then writes via wsclient. What will not happen here is "telling views to write" for you. It's your own glue that will talk to both, you can't get them to talk to each other for you.

Given the broader task though...
I would be setting something up with Views Bulk Operations, actions and rules.
This keeps your unique code to a minimum and produces synergy with the later multipliers.

From the bottom
* create an action that will take data from a single entity and invoke wsclient CREATE on your service. Just once.
Build that working first as - eg, a button on the entity page you can press that invokes the push of a single entry. That's the unique code that may be needed from your end.
* Given that, add the hook_action support to that one action. That will mean you can use content management UI to select one or more items and say 'publish all of these using my mechanism.
* Once that is done, you will find you can also use that action as a button in Views Bulk Operations.
* After that, you will also find you can create a 'Rule' that can be triggered to run your push action every time an item is added (or updated)

Once all those bits are done, you may find that the need to 'build the query in views' may have dissolved. VBO probably did that for you already,

All those later steps are already built. The only thing you have to figure out is
: given an entity data object, map its values into your needed wsclient data packet as args.
: invoke a wsclient action call. ( $response = $service->invoke($operation['name'], $args); )
: .. and how to publish actions to Drupal via hooks