Skip to main content
1-Visitor
May 29, 2015
Question

How To define a remote service in Java SDK

Hi,


I want to call a remote service. Please can any one help in how to define a remote service or service in JAVA SDK and the link to download the JAVA SDK Document.



    5 replies

    1-Visitor
    May 29, 2015

    If you download the latest SDKs you'll find a Java SDK Doc PDF file packaged within it

    Translate
    1-Visitor
    June 16, 2015

    I found this to not be the case. I downloaded the most recent Java SDK and it did not include any documentation whatsoever. The closest I could find therein was the Steam Sensor example files, which do show how to define a remote service and is somewhat useful, but is lacking in terms of full fledged documentation.

    Beyond the ptc support page and the Steam Sensor example I've found very little Java documentation. Is there truly a PDF or doc similar to what is provided for the C SDK? Are there javadocs I am missing?

    Translate
    1-Visitor
    June 16, 2015

    Hi Alex and Rahul

    Can you try to find your answer in the ThingWorx Help Center? http://support.ptc.com/cs/help/thingworx_hc/thingworx_6.0_hc/

    This help center definitely provides documentation for the Java SDK. In the very near future there will be a PDF available with the Java SDK download. In addition, there will be separate Help Center(s) for Edge documentation. However, at this time you can find all Java SDK documentation within the ThingWorx Help Center.

    Hope this helps

    Translate
    12-Amethyst
    June 18, 2015

    Here is an example that might help.

    protected int remoteTimeout=20000;

    .....

    /**
    * This service does a simple thing.
    * <b>Note:</b> This is a remote call to the server
    * @param testValue
    * @param name
    * @throws Exception
    */
    public Double testService(Double testValue, String name) throws Exception {

      ValueCollection paramValues = new ValueCollection();

       // Loop Through Setting parameters
       paramValues.setValue("testValue",new NumberPrimitive(testValue));

      paramValues.setValue("name",new StringPrimitive(name));

      InfoTable infoTable = getClient().invokeService(RelationshipTypes.ThingworxEntityTypes.Things, getName(), "testService", paramValues, remoteTimeout);

       if(infoTable!=null){

       if(infoTable.getRowCount()>0){

       return (Double)infoTable.getRow(0).getPrimitive("result").getValue();

      }

      }

       return new Double(0);

    }

    Translate