SOAP client with node.js and socket.io - php

I am trying to create a web app using Node.js. I want to use socket.io to stream data that I pull from a soap service. I am having trouble finding any information about this. what would be the best option for this situation.
right now:
I am using PHP to call a soap service and retrieve data.
my client side java script makes interval calls using AJAX to the PHP function containing the SOAP call.(this is inefficient which is why I would like to switch to socket.io setup).
What I would like to do:
Node.js app with express possibly
SOAP call using PHP or Node.js if possible.
stream data from SOAP to client side to be viewed using socket.io
I am not sure if this setup is possible and I have not found and good documentation on this. would this be possible ? if so, what would be the best method or is there a tutorial for this?

There is excellent node.js module called 'soap', you may get it via npm install soap. Also see the docs at https://github.com/milewise/node-soap.

Related

Python to front-end communication

I have a web application that uses jQuery (via ajax) to PHP and from there to a MySQL database.
I need to do some ML using Python and reading from the database. My problem is that I am unable to figure out how to communicate from PHP to Python and back to PHP?
For more context, this will be a food recommendation system so on the website, if the user wants recommendations they can select filters (e.g. price range). Now at the moment, this will send a request to PHP and I am trying to pass data to Python run the recommender and get back to PHP with the returned data. Or is there a better way to do this? Like communicate from jquery to Python straight away. (I have Python running the recommender by itself communicating with the database, it just needs the filters that are in jquery)
You could use something like WebSockets to communicate from your front end to the Python backend. WebSockets are basically elevated HTTP sessions which allow for bidirectional transmission.
Mozilla docs have great information on WebSocket API that's built into modern browsers.
Here
This would be if you wanted to communicate straight from the front-end to python. If you wanted to do it from the backend (php), you could establish a socket connection from php to your python program. (TCP). But this might a bit overkill.
Maybe as a simpler alternative, you could create a small Flask web application with an endpoint that can be called by your PHP application (using an HTTP client).
The Flask web app can then make use of all regular Python functionality such as the ML libraries you require and return the result to your PHP application.
Or call the service directly through an ajax request.

How to integrate python/django project with a webservice that provides api only for php?

I work on a django website. Currently, I need to integrate it with a third-party API that provides only PHP endpoints and some shitty documentation that instructs how to build PHP requests. The API provider introduces a PHP client containing a class that handles requests to PHP API webservice via SOAP.
First, is it possible to build python client that will interact with PHP endpoints without knowing server-side trickery of the API provider? Should I dive deeper into PHP client source code and try to rewrite it in python?
Second, should I create intermediary PHP webservice that will integrate third-party PHP API and provide a precise API to interact with python client.
Is there any better option?
P.S. Please, note that I'm new to PHP and SOAP.
Just like any other API. You just have to use the PHP client as a guide to build the API client in python. If you feel it's no help at all, throw it away and look what the endpoints are and what they spit out.
In the end, the endpoints on the remote server can be programmed in Smalltalk for you care. The API client only cares about what parameters to send to the server and what the response looks like.
So pick your basics:
requests for network protocol
soap client
authentication if oauth
and start coding ;) Good luck!

Does drupal or joomla allow a combination node.js and socket.io with php?

I'm looking into the development of a site where socket use is a must for real time updates. I understand with wordpress it is difficult to incorporate node.js and socket.io and was wondering if this is the case with drupal. Specifically could I incorporate node.js and socket.io with php? What specific steps would I need to take? I appreciate the help and of course if you give me a good answer, I'll rate you up.
There are currently Node.js modules that connect to Drupal, Joomla, and WordPress. I wrote the one for Joomla: https://github.com/jlleblanc/nodejs-joomla You can find all of these through NPM. First, you would download one of these modules, then you would also download the Socket.io module. Then you would write server side code connecting the CMS to Socket.io. Finally, you would write client-side code to talk to the socket running in Node.
You can have it separated and since you want some client-server communication with node.js, you can have it - outside Drupal (this is the easiest and cleanest way).
CMS you use (be it Drupal or Wordpress) does not limit your JavaScript from using socket.io and node.js for the calls you want to be made outside the CMS server-side code. You can eg. read the same database Drupal/Wordpress does, but using Node.js and returning the results directly to the client-side JavaScript script.
You can integrate Socket.IO with whatever technology you like, but you need to think of them as 2 separate parts that need to communicate.
I see 2 solutions for Socket.IO to communicate with an external service (Drupal, Joomla, Wordpress, whatever):
1) Making a rest API for your Socket.IO application (for example using Express for the API layer and then passing messages to Socket.IO with an EventEmitter).
2) The better solution in my opinion is to use a message queue like Redis, RabbitMQ or ZeroMQ. The Drupal website would send a message down the channel to Socket.IO and then Socket.IO would send that message to the client(s).
If you are creating a system that needs authentication also, I suggest you don't let your users send message directly with Socket.IO, but make an Ajax call to your main server instead (Drupal for ex.). That way you can check the user's identity more easily. (This scenario would be a fit for a chat based system that requires authentication)
Although this video tutorial is for EventMachine with Faye, the same logic could apply to your app: http://railscasts.com/episodes/260-messaging-with-faye

Publicly available webservice I can use

I am learning to write PHP client programs which call webservices with POST & GET. Is there any publicly available webservice I can use for trying out client programs? Basically, I don't want to get into writing a webservice first before I start trying out client programs - are there any such easy to use webservices I can use?
You can browse through ProgrammableWeb's API directory (REST protocol). What kind of webservice are you looking for in particular?

PHP Soap (Server)

I am trying to create a webservice using the PHP Soap extension and I am having problems with the .wsdl. Is there an easy way to generate 2.0 wsdl's? Where is a good site (or book) that I can look to in order to determine how to build the WSDL? I have no problem getting my soap client to retrieve soap messages from other web services so I know soap is installed and working. I have found a few links out there that generate WSDL's for you, but most of the sites are down. Any help pointing me in the right direction would be helpful
PHP does not have a built-in WSDL generation utility. I would recommend using Zend_Soap_Server which supports WSDL generation via its Autodiscover feature.

Categories