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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to define Input and Output for service created remotely using Java Edge SDK?

mkreinin
1-Newbie

How to define Input and Output for service created remotely using Java Edge SDK?

Hi,

I have a server which connects to thingworx server using Edge SDK and creates remote things. I need to add services for these things. The following code works:

    params = new ValueCollection();

    params.SetStringValue("name", "GetHello");

    params.SetBooleanValue("remote", true);

    params.SetStringValue("remoteServiceName", "GetHello");

    client.invokeService(ThingworxEntityTypes.Things, thingName, "AddServiceDefinition", params, 0);

This creates a service and I can invoke this service provided my virtual thing has an appropriate method. However this service does not accept parameters and has no output.

I tried to add the following to define Output:

    params = new ValueCollection();

    params.SetStringValue("name", "GetHello");

    params.SetBooleanValue("remote", true);

    params.SetStringValue("remoteServiceName", "GetHello");

    client.invokeService(ThingworxEntityTypes.Things, thingName, "AddServiceDefinition", params, 0);

    // add Output type

    ValueCollection entry = new ValueCollection();

    entry.SetStringValue("name", "result");

    entry.SetStringValue("description", "just test");

    entry.SetStringValue("baseType", "STRING");

    InfoTable output = new InfoTable();

    output.addRow(entry);

    params.SetInfoTableValue("resultType", output);

But the service is still created without Output. Can somebody please point me to proper documentation or provide some examples on how to do it?

Thanks,

Michael

0 REPLIES 0
Top Tags