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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Invoking a service java params are coming back as null

justinoberle
10-Marble

Invoking a service java params are coming back as null

I am currently trying to invoke a service but my params are not being set for some reason. This is the java code...

 

//
// Invoking a service on a Thing
///////////////////////////////////////////////////////////////

// A ValueCollection is used to specify a service's parameters
ValueCollection params = new ValueCollection();

params.put("name", new StringPrimitive("testThing"));
params.put("description", new StringPrimitive("Here is thing created from a service via Java."));
params.put("thingTemplateName", new StringPrimitive("RemoteThing"));

 

// Use the CreateNewThing service from SimpleThing_1 to create a new thing.
// This service's result type is NOTHING, so we can ignore the response.
result = client.invokeService(ThingworxEntityTypes.Things, ThingName,
"CreateNewThing", params, 5000);

 

And the service has this javascript within it...

 

var params = {
name: name /* STRING */,
description: description /* STRING */,
thingTemplateName: thingTemplateName /* THINGTEMPLATENAME */,
};


// no return
Resources["EntityServices"].CreateThing(params);

 

For some reason the params set in java code are not being transfered to thingworx javascript. What am I missing here?

2 REPLIES 2

Here is the problem. I still don't know the solution...

Resources["EntityServices"].CreateThing(params);

This line of javascript runs in thingworx but it will not run from Java SDK. It says params is null but it is NOT. I wrote a line in javascript to return the params and it looks identical to when it is run in thingworx. Why is this not running via Java? 

The problem is definitely happening here...

Resources["EntityServices"].CreateThing(params);

I created a new service that creates properties for a thing and ran it via Java and it works. So, the params are there but this line isn't reading them for some reason. I am so confused. Maybe it is a hosted trial issue with creating things specifically? I don't know. Any suggestions would be appreciated.

Top Tags