PI Notifications supports Web Services.

If a Notification matches certain criteria, then it can access a specific URL and perform specific functions with the data.

Since the current version of PI Notifications does not support the custom delivery channel, in order to customize its behavior so that it runs a bat file, writes history to a different database, etc., we wound need to use the PI Notifications Web Service feature. (PI Notifications 2012 had the custom delivery channel, where we could write VB code directly for these tasks.)

 

I want to show a sample configuration that uses the PI Notifications Web Service feature.

For more information, one can refer to the PI System Explorer user guide.

https://techsupport.osisoft.com/Downloads/File/44dba67d-6396-45fe-b6cd-29225f96b4c5

Additional information is also available in Live Library.

https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v9/GUID-0412404B-08DF-4C84-ABD8-09DA15A08BA3

 

This blog post only shows how to configure SOAP and REST web services for PI Notifications 2017. I hope it helps anyone who wants to configure it.

 

In PI Notifications 2017, you can send requests to SOAP web services and REST web services.

There are many differences between SOAP and REST.

https://blog.smartbear.com/apis/understanding-soap-and-rest-basics/

However, in PI Notifications, the difference is as follows.

REST can send a JSON object to the REST server. (PUT, POST, PATCH)

SOAP can call the Web Service's methods.

The PI System Explorer user interface automatically retrieves the associated Web Service Definition Language (WSDL) methods, provides useful information about the parameters, and guides you through configuring the web service.

 

Now, we will go ahead and create a SOAP or REST Delivery Endpoint from PI System Explorer > Contacts.

When using SOAP, it will require the Web Service Address. This should be developed by your company or you can also access a third party web service.

Since this is test, I will use GlobalWeather as an example.

It shows the GetWeather method but if you want to write values, etc., then the Web Service drop down should have Put methods, etc. This will depend on the Web Service server.

 

If you want to use REST, you will need the Url and the http method.

I used the PI UFL Connector's address for the URL. (I don't want to write back to PI but I want to check the contents of the PUT request. That is why I used the PI UFL Connector. It is easy to log the body of the request.)

It has REST server functionality and I can see the contents of the request's body in the logs.

 

After creating these, let’s configure the PI Notification.

Please go to the Notification Rules tab on the specific element.

Click the View/Edit Subscriptions link in the Subscriptions section.

From Contacts, find the Delivery Endpoint and drag and drop it to the Subscriptions pane.

Click the wrench icon to configure it.

For configuring a REST service, the Path is related to how your Web Service server is configured.

What JSON format does the web service want to receive?

The help file contains the following example.

 

If you want to receive the element name and attribute names/values then the following is an example.

For getting the element name, you can use Referenced Element Properties > Name.

For getting the attribute names or values, you can use Attribute[n].Name and Attribute[n].Value

Now, the JSON Object should show the element name, attribute names and values.

(I used the PI UFL Connector REST Server method with an INI file that contains print(__Message) which can log the contents of the request to the PI Message log. The PI UFL Connector requires Basic authentication but I changed it to anonymous)

Formatted it to the JSON.

{

                "ElementName": "HOU.Press.01",

                "Attribute": [{

                                "Name": "Curing Phase",

                                "Value": "Waiting"

                }, {

                                "Name": "Mold Temperature",

                                "Value": 40.121231079101563

                }, {

                                "Name": "Pressure",

                                "Value": 0.0

                }]

}

It is the expected format.

 

There is no authentication for PI Notification 2017 but in future version (2017 R2) basic authentication will be available.

https://feedback.osisoft.com/forums/555148-pi-server/suggestions/20102842-enable-authentication-headers-for-soap-and-rest-we

A screenshot from the beta version is as follows.

I used the PI System Explorer (GUI) to configure it.

If you need to configure multiple items in bulk, you can use PI Builder.

You can add new lines for new attributes by copying the existing attributes.

See the DeliveryFormatPropertyValue row. There are fields for ID and PropertyID in the ContentInfo. These are the same for all attributes.

So you only need to rename the Name part in the DeliveryFormatPropertyValue’s ContentInfo.

Now I exported it correctly and could see it from PI System Explorer too.

In the Excel sheet, you will find a "NewFormat" name for the DeliveryFormat object. Unfortunately we cannot change this from the GUI. If you create multiple Notification Rules, the name will become "NewFormat1".

For configuring these in bulk, element templates can also be used.

Please use templates for configuring it in multiple elements.