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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to pass json input from Thingworx to an external java code for creating custom extension?

kkgooner
5-Regular Member

How to pass json input from Thingworx to an external java code for creating custom extension?

Hi,

I need to create a custom PDF extension widget for Thingworx. This widget should be able to export the data ( infotable containing of many rows and columns) shown in thingworx as a PDF. For my testing purpose, I created a sample Json file in my local computer and used that as a source for the java code to get the PDF generated.

 

Now how I have to test using the data coming from Thingworx. Can you please suggest me how can I achieve this? The json data from thingworx should be passed as the input to my java code where pdf is generated.

Much thanks..

1 ACCEPTED SOLUTION

Accepted Solutions

Hi, I have not tried what you suggested. Some one in the community might help you out with that. But what I am trying to suggest is create a Web Service or Rest API in your Java code. I believe you can invoke this API from ThingWorx service, through the code snippets which I have mentioned earlier, and pass the JSON values. Again, this might not be the best option and what you have suggested might work. But this is also a way you can achieve what you are looking for. Hope this helps!  

View solution in original post

3 REPLIES 3

ThingWorx provides ability to make calls to Web service. Refer to the code snippets section which is available to you while creating a service and find the ContentLoaderFunctions section. Here you can find different methods to export/import json through ThingWorx to an external program. 

kkgooner
5-Regular Member
(To:Rajesh_Sayana)

Hi,

 

Thank you for your response. I will have a look. Whatever you said is applicable for a custom extension that I will be importing into thingworx? Because I need to pass data from one thingworx service (json output) to this widget ( where that data will be the input)

Also, based on your reply, I have got the below idea. Please let me know if its feasible.

1.In my custom widget java code, I have defined @ThingworxServiceDefinition( name="pdfservice").

2. So once I import the extension to Thingworx, I create a Thing for this extension and map this pdfservice to this thing.

3. Then in the input section of this pdfservice, I can pass the service that provides the initial json data that will be used for the pdf reports.

 

Not sure about the logical flow of this, but just got a rough idea. Let me know if this is feasible in Thingworx. Thanks

Hi, I have not tried what you suggested. Some one in the community might help you out with that. But what I am trying to suggest is create a Web Service or Rest API in your Java code. I believe you can invoke this API from ThingWorx service, through the code snippets which I have mentioned earlier, and pass the JSON values. Again, this might not be the best option and what you have suggested might work. But this is also a way you can achieve what you are looking for. Hope this helps!  

Top Tags