Create and Expose WebService

Hi there,
Can anyone please provide any insight on

  • how to create a WebService in the IDE and link it one of the Entity editor screen in the CUBA Platform?
    I was not able to finding any sample code related to this topic.

Thank you.

Hi,

Have you looked at the generic REST API? It allows you to expose CRUD operations with entities and much more.

1 Like

Hi there - Thanks for your response.

I have looked at the REST API link that you provided above. The information provided there is very high level and I wasn’t able to proceed any further with it.

I was hoping to find a very basic REST API working code which can give an insight into how it all works. For example the bicycle app provided by cuba platform was very helpful in understanding how to create and use a service with entities.
I was hoping to get similar or more informative document which can help me understand how to create and call webservice with entities.

Any leads on that front?

I wanted to try this option:

https://www.jetbrains.com/help/idea/2016.3/exposing-code-as-web-service.html

I already have a running code from the bicycle app. I wanted to use the expose the class that I have created in the bicycle app as a webservice

but when I select my class, I do not see the option ‘Expose as web service’.

Hi,

The platform doesn’t have features for exposing SOAP web services (you meant them, right?). If you want to create and use SOAP web-service, you can use any java library for this in a standard way.

However, platform has RESTful web services. They work out of the box, you don’t need to write any additional server-side code. Take a look at the REST API Usages Examples section. It will give you examples of http-requests for getting an OAuth-token, getting a list of entities, and so on. You can use any http client for experiments with REST API (Postman for example).

There is also an example of java-script code for invoking REST API in the “Usages” section.

1 Like

Thanks for your response Max. Please allow me to elaborate further.

Yes, I am talking about SOAP web services. I had created a webservice outside the CUBA platform (as it does not a feature to create SOAP webservice) in the IDE ( I used ItelliJ IDEA) that is linked to my CUBA project.

So I created another package for the webservice and added the webservice code there. But this webservice code is added to the auto generated CUBA project code in the IDE.

So at this stage, is it possible to use my Webservice to be able to interact with the underlying CUBA database (that was auto generated by CUBA for the various entities/screens)?

Example - I created Orders (entity and its associated browser & edit screen) for test purpose in the CUBA platform. The Orders screen has about 5 fields. While I am able to create/ edit orders on the fly via the excellent user interface from CUBA.

So can I use my SOAP web service directly to create the Orders without accessing the Order entity -create screen in the CUBA platform? Is this sort of integration is not possible in CUBA?

The above scenario is just an example for what I am looking to do. There may be some instances where in it would be more efficient to just create the application data via SOAP webservice in the backend and other instances where in the such activities are performed directly via the CUBA screens.

Thank you for your time! I appreciate your all responses.