ThingWorx Edge Java SDK > Application Details > VirtualThing Component > Remote Services
  
Remote Services
Unlike local services that execute on the ThingWorx platform, remote services execute on your device. Remote services can be executed just like local services. However, their input and output definitions and implementation are defined by your edge application.
You can easily pull remote services onto your thing on the ThingWorx platform by navigating to the Services tab and clicking Browse Remote Services.
Service Definitions
Service definitions describe actions or operations that the ThingWorx platform can call on the virtual thing. A service may have several or no inputs but only one result. The most effective and maintainable way to define services is with annotations (listed below). Both declarative and explicit code examples are outlined.
ThingWorxServiceDefinition — Add this to a method to indicate that this is a service that the ThingWorx platform can use.
name — A label for the service.
* 
This name must match the name of the Java method.
description — An explanation of the action or operation provided by the service.
ThingWorxServiceResult — Add this to a method to indicate the result of the service.
name — A label for the result for the ThingWorx platform to use when presenting the result. This name should always be result and a constant is defined for it: CommonPropertyNames.PROP_RESULT.
description — Explanatory information for the result.
baseType — The base type of the result. The value of this parameter is a string value, representing the possible base types. For a table of available base types, refer to the section, Base Types and Primitives.
* 
To indicate a void result, use the base type, NOTHING.
ThingWorxServiceParameter — Append this to each input parameter.
name — A label for the parameter.
description — Explanation of the parameter.
baseType — The base type of the parameter. The value is a one of the possible base types. For a table of available base types, refer to the section, Base Types and Primitives.
Example of a Service That Adds Numbers
The following service returns the results of adding two numbers::
@ThingWorxServiceDefinition(

name="Add",
description="Add two numbers")

@ThingWorxServiceResult(
name=CommonPropertyNames.PROP_RESULT,
description="The sum of the two parameters",
baseType=BaseTypes.NUMBER.name())

public Double Add(

@ThingWorxServiceParameter(
name="p1",
description="The first addend of the operation",
baseType=BaseTypes.NUMBER.name()) Double p1,

@ThingWorxServiceParameter(
name="p2",
description="The second addend of the operation",
baseType=BaseTypes.NUMBER.name()) Double p2)

throws Exception {
return p1 + p2;
}

//The following service returns the current date and time

@ThingWorxServiceDefinition(
name="WhatTimeIsIt",
description="Returns the current time")

@ThingWorxServiceResult(
name= CommonPropertyNames.PROP_RESULT,
description="",
baseType=BaseTypes.DATETIME.name())

public DateTime WhatTimeIsIt() {

return new DateTime();
}

//The following service takes no parameters and returns nothing

@ThingWorxServiceDefinition(
name="SimpleService",
description="Returns nothing")

@ThingWorxServiceResult(
name=CommonPropertyNames.PROP_RESULT,
description="",
baseType=BaseTypes.NOTHING.name())

public void SimpleService() {

//Do something here...
}