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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Calling Thingworx Service Using Java Extension SDK

bwinslow24
12-Amethyst

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

ACCEPTED SOLUTION

Accepted Solutions

@slangley ,

 

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);

View solution in original post

4 REPLIES 4
CRArko
17-Peridot
(To:bwinslow24)

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 

slangley
23-Emerald II
(To:mnarang)

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

@slangley ,

 

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);

Announcements


Top Tags