How to query data from an AspenTech IP21 Historian using PHP?

tburd picture tburd · Oct 13, 2017 · Viewed 7k times · Source

Is it possible to query data from InfoPlus 21 (IP21) AspenTech using php?

I am willing to create a php application that can access tags and historical data from AspenTech Historian.

Is ODBC my answer? Even thinking that is, I am not quite sure how to proceed.

UPDATE: I ended up using python and pyODBC. This worked like a charm! Thank you all for supporting.

Answer

Marty131 picture Marty131 · Oct 16, 2017

I am unaware of a method to access IP21 data directly via PHP, however, if you're happy to access data via a web service, there are both REST and a SOAP options.

Both methods are extremely fast and responsive.

AFW Security still applies to clients accessing the Web Services. Clients will require SQL Plus read (at lesast) access.

SOAP

  • Requires the "Aspen SQL plus Web Server/Service and Health Monitor" component to be installed on IP21 server (Selected during install of IP21).
  • Recent versions of IP21 require a slight modification to the web.config file to allow remote access. If you cannot execute the web service remotely, try doing it locally (i.e. on the same machine as the IP21 server) and see if this is an issue.

    • Example: http://IP21ServerHostName/SQLPlusWebService/SQLplusWebService.asmx/ExecuteSQL?command=select%20*%20from%20compquerydef;

REST

  • My preference (over SOAP), as it is super easy to access using JQuery (JavaScript) - a couple of lines of code!
  • Unsure of exactly what IP21 component is required on install for this, but it appears to be on most of my IP21 servers already.
  • Arguments in the URL can control the number of rows returned (handy).
  • If using within Jquery / JavaScript, web page must be hosted on the AspenOneServerHostName machine, else you'll run into Cross-Origin Resource Sharing (CORS) issues.

    • Example: http://AspenOneServerHostName/ProcessData/AtProcessDataREST.dll/SQL?%3CSQL%20c=%22DRIVER={AspenTech%20SQLplus};HOST=IP21ServerHostName;Port=10014;CHARINT=N;CHARFLOAT=N;CHARTIME=N;CONVERTERRORS=N%22%20m=%22DesiredMaxNumberOfRowsReturned%22%20s=%221%22%3E%3C![CDATA[select%20*%20from%20compquerydef]]%3E%3C/SQL%3E
      • Notes:
        • AspenOneServerHostName can be the same as IP21ServerHostName
        • AspenOneServerHostName must have ADSA configured to view IP21ServerHostName
        • Replace DesiredMaxNumberOfRowsReturned with a number