Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [basyx-dev] Query on invoking Operation with REST API

Hello Mr. Conradi,

I am able to invoke the operation after changing the elements of the operation from Property type to OperationVariable type as shown below. And the post request body provided by you helped to make it work.

Thanks for your assistance.


        Operation complex = new Operation((Function<Object[], Object>) v -> {
            System.out.println("complex is invoked ");          
            return new String("MyOutput");
        });      
 
        complex.setIdShort("complex");
 
        OperationVariable a = new OperationVariable(new Property("finput", "myDefaultInputString"));      
        OperationVariable r = new OperationVariable(new Property("foutput", "myDefaultoutputString"));
        complex.setInputVariables(Arrays.asList(a));
        complex.setOutputVariables(Collections.singletonList(r));
 
        edgeSm.addSubmodelElement(complex); 



Best Regards,

Nayabrasul shaik.


On 22.11.21 16:23, Nayabrasul Shaik wrote:

Hello Mr. Conradi,

Thanks for your reply.

I tried invocation of operation with the Json body you provided and the result was same as before. Basyx side is crashing with the same error as mentioned in the previous mail.

I tried adding the valueId to body but the invocation was unsuccessful.

For your information, following are the example files I was using. 

CloudEdgeDeploymentScenario.java

ComponentBuilder.java


Best Regards

Nayabrasul Shaik


On 22.11.21 14:13, maximilian.conradi@xxxxxxxxxxxxxxxxxx wrote:

Hello Mr. Shaik,

 

thank you for your message.

I think the exception you are getting is caused by a slightly wrong body you use for your request.

The correct body should look like this:

 

{

"requestId" : "1",

"inputArguments": [

    {

      "value": {

           "idShort": "finput",

           "valueType": "string",

           "value": "MyInput",

           "modelType": {

               "name": "Property"

           }

      }

    }

  ],

    "timeout" : 5000

}

 

Some of the content of “value” needs to be slightly different to what you had.

I hope this helps.

 

Kind regards

Maximilian Conradi

 

--

Maximilian Conradi

Software Architect

Dept. Virtual Engineering

 

Fraunhofer IESE

Fraunhofer-Platz 1 | 67663 Kaiserslautern

+49 631 6800 2278
maximilian.conradi@xxxxxxxxxxxxxxxxxx

www.iese.fraunhofer.de

 

 

 

 

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

Von: basyx-dev <basyx-dev-bounces@xxxxxxxxxxx> Im Auftrag von Nayabrasul Shaik

Von: basyx-dev <basyx-dev-bounces@xxxxxxxxxxx> Im Auftrag von Nayabrasul Shaik
Gesendet: Dienstag, 16.
November 2021 16:28
An:
basyx-dev@xxxxxxxxxxx
Betreff: [basyx-dev] Query on invoking Operation with REST API

 

Dear Basyx Developers Community,

I am Nayabrasul Shaik, working for Service Robotics Research Center at the Ulm University of Applied Sciences, Germany.
Our group is currently working on providing AAS interface to the Service Robots. We choose Basyx implementation for this purpose and appreciate your effort.


I have a query on invoking the operation using the REST interface. I am using the
Cloud Edge Deployment example for this purpose.


I added an Operation(which takes a string as input and returns a string) to Submodel and tried to invoke it using Postman rest client.
The response from REST api is unsuccessful and I see the following error in Basyx.


Error from Basyx:
-------------------------
15:56:39.870 [http-nio-8082-exec-5] ERROR org.eclipse.basyx.vab.coder.json.provider.JSONProvider - Unknown Exception in JSONProvider
org.eclipse.basyx.aas.metamodel.exception.MetamodelConstructionException: Could not construct meta model element org.eclipse.basyx.submodel.metamodel.map.submodelelement.operation.OperationVariable. Passed argument was {modelType={name=OperationVariable}, value={valueId=null, kind=Template, valueType=string, modelType={name=Property}, value=foutput}}
    at org.eclipse.basyx.submodel.metamodel.map.submodelelement.operation.OperationVariable.createAsFacade(OperationVariable.java:69)
   
   

Below snippet shows the operation added to submodel:
-----------------------------------------------------------------------------

        complex.setIdShort("complex");       
        Property inProp1 = new Property("finput");
        inProp1.setModelingKind(ModelingKind.TEMPLATE);
        inProp1.setValueType(ValueType.String);
       
        Property outProp = new Property("foutput");
        outProp.setModelingKind(ModelingKind.TEMPLATE);
        outProp.setValueType(ValueType.String);
       
        complex.setInputVariables(Arrays.asList(new OperationVariable(inProp1)));
        complex.setOutputVariables(Collections.singleton(new OperationVariable(outProp)));       
               
        edgeSm.addSubmodelElement(complex);



Following is the REST API used and JSON input used for invoking the operation:
-------------------------------------------------------------------------------------------------------------

POST
http://localhost:8082/oven/curr_temp/submodel/submodelElements/complex/invoke


{
"requestId" : "1",
"inputArguments": [
    {
      "value": {
        "idShort": "finput",
        "category": "string",
        "kind": "Template",
        "value": "MyInput",
        "mimeType": "string"
      }
    }
  ],
    "timeout" : 5000
}



I appreciate any cues in getting the successful response for REST API invocation of operation.
Thanks in advance.


--
Mit freundlichen Grüßen / Kind regards

Nayabrasul Shaik

Research associate
Service Robotics Research Center
University of Applied Sciences Ulm
Prittwitzstrasse 10
89075 Ulm
Germany
Telefon: +49 (0731) 50-28148
E-Mail:
nayabrasul.shaik@xxxxxx

 


_______________________________________________
basyx-dev mailing list
basyx-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/basyx-dev

Back to the top