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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to expose local java service implementation in metadata.xml for Thing shape ? Used ServiceDefinition/ServiceImplementation/HandlerDefinitions. There is error "No service handler defined for service"

ptc-89213
6-Contributor

How to expose local java service implementation in metadata.xml for Thing shape ? Used ServiceDefinition/ServiceImplementation/HandlerDefinitions. There is error "No service handler defined for service"

Want to define a ThingShape that has a local java method (not java script) exposed as service. Hence the ThingShape class has the required method with annotation ThingworxServiceDefinition/ThingworxServiceResult..

Want to expose The same method is then added in metadata.xml so that service is available to things. Tried to use Reflection Handler definition and it lists the service on thing shape as well as thing created using the thing shape defined. However when we test, it return the error ..

Unable to Invoke Service PTCGetAllThingsData on Mt2 : No service handler defined for service PTCGetAllThingsData on thing [Mt2]

----------------------------------------

Server method declaration in Thing Shape ...

@ThingworxServiceDefinition( isLocalOnly=true, name="PTCGetAllThingsData", description="Get implementing things" )

  @ThingworxServiceResult( name="Result", description="Result", baseType="STRING" )

  public String PTCGetAllThingsData () throws Exception {

-...........

}

---------------------------

The example metadata.xml

<Entities>

  <ExtensionPackages>

.....................

  </ExtensionPackages>

  <ThingPackages>

  <ThingPackage name="PTCThingShapeExtPackage" description="Sample Extension" className="com.ptc.exps.PTCThingShapeExp" aspect.isSystemObject="false" aspect.isCreatable="true" >

  <HandlerDefinitions>

            <HandlerDefinition name="Reflection" className="com.ptc.exps.PTCThingShapeExp"/>

  </HandlerDefinitions>

  <JarResources>

  <FileResource type="JAR" file="thingworx-ptcthingshape-extension.jar" description="PTC ThingShape Extension Package JAR" />

  </JarResources>

  </ThingPackage>

  <ThingShapes>

  <ThingShape name="PTCThingShapeExp" description="PTC Thing Shape Extension" className="com.ptc.exps.PTCThingShapeExp" aspect.isSystemObject="false" thingPackage="PTCThingShapeExtPackage">

  <ServiceDefinitions>

  <ServiceDefinition aspect.isAsync="false" description="sds" isAllowOverride="false" isLocalOnly="false" isOpen="false" isPrivate="false" name="PTCGetAllThingsData">

            <ResultType baseType="STRING" description="" name="result"/>

             </ServiceDefinition>

        </ServiceDefinitions>

        <ServiceImplementations>

  <ServiceImplementation handlerName="Reflection" name="PTCGetAllThingsData" allowOverride="false" />

  </ServiceImplementations>

        </ThingShape>

  </ThingShapes>

2 REPLIES 2

I am also looking for an answer to this question.

I am also looking for an answer to this question.

If somebody could answer, it would be better.

Top Tags