Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I have a program written in java and i want to display its output in Thingworx.
Can anybody please suggest is there any way to implement this???
Solved! Go to Solution.
I have worked on the java connection with thingworx and i have done it through java edge sdk and it works perfectly.
Try below:
declare below constructor:
public classname(ClientConfigurator config) throws Exception {
super(config);
}
use below code:
ClientConfigurator config = new ClientConfigurator();
config.setUri("ws://ipaddr:port/Thingworx/WS");
config.ignoreSSLErrors(true);
config.setAppKey("applicationKey"); //application Key which you have created in thingworx
classname client = new classname(config);
client.start();
InfoTable result;
//Declaer values to input in service
ValueCollection params = new ValueCollection();
params.put("maxItems", new IntegerPrimitive());
//create service in data tabe if you want to fetch data in it and use it in invoke service
//To read all the values from the Data table of Thingworx with things
result = client.invokeService(ThingworxEntityTypes.Things, "thingname", "servicename", params, 5000);
To update in data table:
ValueCollection value = new ValueCollection();
value.SetStringValue("Status", status); // field you want to give input in service
client.invokeService(ThingworxEntityTypes.Things, "datatablename", "servicename", value, 5000);
Kedar Borkar, Is it a Standalone application or is the code part of ThingWorx extension.
If it's a Standalone extension; you can use REST API to post the data to a property and then use that property on Mashup.
If it's part of an extension; you can save it in a property and use that property on Mashup.
I hope it helps.
Thanks,
Ankit Gupta
Can you please provide some link or example so that i can explore that and use it in my java code as i am new to thingworx and not getting enough content to start with.
If you can provide some link with example for Rest API... and moreover i don't have any censor attached i just want to display my fields of java in thingworx.
Hi Kedar Borkar, Here is a good link for Rest Api in ThingWorx: ThingWorx REST API Cheat Sheet
You would require to do a HTTP post from your Java program to post data to a Property of a Thing in ThingWorx.
Then you can use that property to show data on Mashup.
For more help on ThingWorx you can check the Help guide: PTC ThingWorx Help Guide
I have worked on the java connection with thingworx and i have done it through java edge sdk and it works perfectly.
Try below:
declare below constructor:
public classname(ClientConfigurator config) throws Exception {
super(config);
}
use below code:
ClientConfigurator config = new ClientConfigurator();
config.setUri("ws://ipaddr:port/Thingworx/WS");
config.ignoreSSLErrors(true);
config.setAppKey("applicationKey"); //application Key which you have created in thingworx
classname client = new classname(config);
client.start();
InfoTable result;
//Declaer values to input in service
ValueCollection params = new ValueCollection();
params.put("maxItems", new IntegerPrimitive());
//create service in data tabe if you want to fetch data in it and use it in invoke service
//To read all the values from the Data table of Thingworx with things
result = client.invokeService(ThingworxEntityTypes.Things, "thingname", "servicename", params, 5000);
To update in data table:
ValueCollection value = new ValueCollection();
value.SetStringValue("Status", status); // field you want to give input in service
client.invokeService(ThingworxEntityTypes.Things, "datatablename", "servicename", value, 5000);