Creating a Thing from a Virtual Thing Service (Java SDK)
Hi All,
I am attempting to use the Java SDK to create a virtual thing that will create a new remote thing on the TWX server, and eventually have the virtual thing and remote thing automatically bound.
I've created a service on the virtual thing (below) that should allow me to do that, but I am running into problems when I try to initiate that via the remote service browser in TWX.
Here's my java code...
@ThingworxServiceDefinition(name = "Create_Remote_Thing", description = "Creates a remote thing on the server")
@ThingworxServiceResult(name = "result", description = "There is no result", baseType = "NOTHING")
public void Create_Remote_Thing(
@ThingworxServiceParameter(name = "ThingName", description = "The name of the thing that is to be created", baseType = "STRING") String name,
@ThingworxServiceParameter(name = "ThingTemplate", description = "This is the name of the template that is being inherited", baseType = "THINGTEMPLATENAME") String template,
@ThingworxServiceParameter(name = "Description", description = "The description for the thing being created", baseType = "STRING") String description) throws TimeoutException, ConnectionException, Exception {
ValueCollection params = new ValueCollection();
params.put("name", new StringPrimitive(name));
params.put("thingTemplateName", new StringPrimitive(template));
params.put("description", new StringPrimitive(description));
ClientConfigurator config = new ClientConfigurator();
ConnectedThingClient myclient = new ConnectedThingClient(config);
myclient.invokeService(ThingworxEntityTypes.Resources, "EntityServices", "CreateThing", params, 5000);
myclient.invokeService(ThingworxEntityTypes.Things, name, "EnableThing", null, 5000);
myclient.invokeService(ThingworxEntityTypes.Things, name, "RestartThing", null, 5000);
}
This service is now visible on the server, and property values are streaming when I open a connection. That said, I am getting this error when trying to remotely test the service…
Unable to Invoke Service Create_Remote_Thing on Simple1 : No open connections were available on endpoint 17
I’m not quite sure why this would happen while data is streaming, since it seems that a connection is clearly open. My full code can be found here:
https://github.com/PTCMCheli/EdgeConnector/tree/Remote_Services/src/com/ptc/edgeconnector/simulator
Also yes, I have looked extensively at the documentation here: http://support.ptc.com/cs/help/thingworx_hc/thingworx_edge/
Thanks!

