eclipse-basyx / basyx-java-server-sdk

MIT License
55 stars 45 forks source link

Issue with Invokable Operation for File Input in Submodel #309

Open inowshin19 opened 3 months ago

inowshin19 commented 3 months ago

I am trying to use an invokable operation for file input in my Submodel using Postman. My Submodel and its element is defined as follows:

{
  "paging_metadata": {},
  "result": [
    {
      "modelType": "Submodel",
      "kind": "Instance",
      "id": "TestOrchestrator",
      "category": "TestCategory",
      "description": [
        {
          "language": "de-DE",
          "text": "TestOrchestrator"
        }
      ],
      "displayName": [
        {
          "language": "de-DE",
          "text": "TestOrchestrator"
        }
      ],
      "idShort": "TestOrchestrator",
      "submodelElements": [
        {
          "modelType": "Operation",
          "inputVariables": [
            {
              "value": {
                "modelType": "File",
                "contentType": "application/json",
                "idShort": "aasFile"
              }
            }
          ],
          "idShort": "AASUpload"
        }
      ]
    }
  ]
}

I am sending a POST request via Postman to the endpoint:

http://localhost:8081/submodels/VGVzdE9yY2hlc3RyYXRvcg/submodel-elements/AASUpload/invoke?async=false

The form-data and response is given below:

GithubIssue_FileInvokable

Is file not supported for input? Please let me know if I am doing something wrong.

Thank you very much in advance!

aaronzi commented 3 months ago

Thank you for submitting this issue. We will look into it and get back to you with a solution.

zhangzai123 commented 3 months ago

Hi @inowshin19 , the invokable operation is developed by the Basyx SDK, it is not included in the AAS4j or AAS standard, so you cannot create an invokable operation using a Json file. Here is an example to create an invokable operation

From your provided information I understand that you want to upload an AAS defined in the opc2aasServiceAAS.json.
The best way to upload an AAS ist to use the follow HTTP REST API: POST {server-url}/shells body: serialized AAS as Json see here

inowshin19 commented 3 months ago

Hello @zhangzai123, thank you for the clarification!

zhangzai123 commented 3 months ago

Hi @inowshin19, I have tested your settings in a Junit test. The test runs through without error. It may because of the usage of the Postman that you got the 415 error.

gongzhq136 commented 2 months ago

I also came cross a problem regarding invokable operation. I create a submodel using createSubmodelWithAllSubmodelElements and create the submodel in SubmodelRepository with the createSubmodel method. After this I got error when I execute the operation, no matter via web-ui (got 405 Error) or via invoke API (got NotInvokableException).

However, if i create the submodel via the SubmodelRepository instance which returned from appContext.getBean(SubmodelRepository.class), it works indeed.

Hi @inowshin19 , the invokable operation is developed by the Basyx SDK, it is not included in the AAS4j or AAS standard, so you cannot create an invokable operation using a Json file.

Is it now possible to create a submodel in submodelrepository component which supports invokable operation directly, rather than through operation delegation? Please let me know if I'm missing something. Much appreciated!

mateusmolina-iese commented 2 months ago

Hi @gongzhq136,

invoking operations directly without the operation delegation feature is currently not supported.

I'll add your suggestion to the backlog for future consideration 👍