0 Replies Latest reply on Jul 5, 2016 5:26 PM by mkreinin RSS
    mkreinin 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