Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hi,
I have a custom service on a Database Thing. I want to call that custom service from my Java Extension. My first thought is to do something like this
Thing myDB = ThingUtilities.findThing("MyDataBase");
InfoTable result = myDB.customService();
Is this the correct way?
Thanks,
Brandon
Solved! Go to Solution.
None of these solutions were correct. The way I was able to get it working was with this code:
Thing db = ThingUtilities.findThing("dbThing");
InfoTable result = db.processServiceRequest("customService", null);
Hi, Brandon.
One thing you might want to consider is adding some exception handling to the call to the Service.
See this article for some discussion and techniques for doing that.
Thanks,
-- Craig A.
If you want to search for your thing and then execute the service .You should find the thing like
Thing mything =(Thing)EntityUtilities.findEntity("MyDBThing",ThingworxRelationshipTypes.Thing);
So the MyDBThing is the thing in composer and then you can proceed with the call of service keeping the return type in mind like mything.myservice();
For better design you should place this in try catch block .
Thanks ,
Mukul Narang
Hi @bwinslow24.
If one of the previous responses answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
None of these solutions were correct. The way I was able to get it working was with this code:
Thing db = ThingUtilities.findThing("dbThing");
InfoTable result = db.processServiceRequest("customService", null);