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

Calling Thingworx Service Using Java Extension SDK

SOLVED
Regular Member

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Calling Thingworx Service Using Java Extension SDK

@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

Re: Calling Thingworx Service Using Java Extension SDK

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.

Re: Calling Thingworx Service Using Java Extension SDK

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 

Re: Calling Thingworx Service Using Java Extension SDK

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

Re: Calling Thingworx Service Using Java Extension SDK

@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