Calling Thingworx Service Using Java Extension SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Calling Thingworx Service Using Java Extension SDK
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.
- Labels:
-
Best Practices
-
Coding
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
