cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Display Service Response of Remote thing's Set Properties in Thingworx Mashup

Ramkumar
10-Marble

Display Service Response of Remote thing's Set Properties in Thingworx Mashup

I am trying to set properties of a remote thing from mashup dashboard.

I can set properties using one of the following

1.Mashup only service

-SetProperties

2.Snippets that can be called from custom service

-UpdatePropertyValues

-UpdateSubscribedPropertyValues

-SetPropertyValues

 

All of the above have output type NOTHING.I want to retrieve the output(i.e http response if any) and display error message in mashup if service call failed due to some reason. Eg: Edge device not connected or some custom error message from remote thing's script handler

 

Is there any way to retrieve the response/output when trying to set properties to remote thing from service?

 

Note:

Thingworx Composer displays error message when trying to set property from Thing's properties.Looking to implement  a similiar functionality from thingworx dashboard.

set-remote-prop-error.pngset-remote-prop-error1.png

ACCEPTED SOLUTION

Accepted Solutions

On the custom service part, if you add a try{} catch(err) {} wrapping the SetPropertiesValues what you get?

View solution in original post

6 REPLIES 6

If you click on Bindings button of the Service call on the mashup it will pop-up a window which allows you to set a optional pop-up for service call answer with:

 

  • Show Success Notifications
  • Show Error Notifications

 

That can be a way, another way could be to build your own custom service that sets the desired property and checks for remote connectivity and it returns as output a success message or a error message and you use this message (when error for instance) to pop-up a "Status Message" widget.

Currently I am using default service's 'Show success/error Notifications' from service configuration to display status message

 

I have used SetPropertyValues to set properties.

I need to know if SetPropertyValues failed due to some issue on the remote thing and identify error based on service response and show custom success/error message instead of using default message.

 

Also I am trying to call another service on SetPropertyValues service's ServiceInvokeCompleted event, which is not getting fired if SetPropertyValues fails(with 500 status code).

 

Is there any way to get a service's call status and response?

 

Note:

On using custom service, we still need to call one of the available snippets to set properties on the thing (output is NOTHING for all of those built-in snippets for setting properties). So still need to find a way to identify whether service succeeded/failed

With the custom service approach you can check if the thing it's connected before calling the builtin service and act accordingly for instance.

Yes, agree.

 

I have a use case where we are reading and writing values to remote thing using script handlers and if something failed during read/write, then we are returning 500 from script handler.

 

So checking connection status alone will not work in this case.

 

If we could access response for setPropertiesValues (or any other built-in service that setProperties), then I could display message accordingly.

 

Also,as mentioned earlier, setPropertiesValues service's ServiceInvokeCompleted is not getting fired when service fails.

On the custom service part, if you add a try{} catch(err) {} wrapping the SetPropertiesValues what you get?

I am able to track error response using try ... catch.

 

Initially I was trying to return SetPropertiesValues response for custom service which was always returning 200 and at the same time I was getting exception in the script monitor(missed to see logs).

 

By wrapping SetPropertiesValues service in custom service (in try ... catch), I able to get success/failure message.

 

When calling SetPropertiesValues service directly and if the service fails,it still returns 200 response and ServiceInvokeCompleted is not getting called.Is it because output of SetPropertiesValues is NOTHING?

 

Adding another observation:

When set properties by directly calling  SetPropertiesValues taking less time than when wrapping the same in custom service.Eg: If SetPropertiesValues service is taking 10s to 15s, custom service is taking 20s to sometimes 45s.(it is twice than normal time)

 

Please let me know if wrapping a built-in service in a custom service would take more time than directly calling the service itself

Announcements


Top Tags