Exposing Web Services From Business Components

     Each new line of code you write is a potential bug. Moreover, each line of code you add to your existing applications reduces your ROI. On the other hand, service integration is more important today than ever. Did you know that you can leverage the Oracle ADF applications 642-384 you already have to build […]

by Denis Danov

March 28, 2014

3 min read

image 286 - Exposing Web Services From Business Components

     Each new line of code you write is a potential bug. Moreover, each line of code you add to your existing applications reduces your ROI. On the other hand, service integration is more important today than ever.

Did you know that you can leverage the Oracle ADF applications 642-384 you already have to build web services? This blog is going to explain this process.

The Pattern   PV7K75GBXuaNyOnqYhWdod29lvvOSk2eawUO8pOA1W9UF9Chy1bgZTj nA lpUmM2C63SRyb1lbV7PYDcDsl6MK7cA2McD5SwZ PbrskamzGtQu4Sdkg8tbftNU Yw - Exposing Web Services From Business Components

First of all, let me describe a pattern that can be useful when exposing BC’s as web services. That pattern is called “Facade” and it is commonly used with object-oriented programming. This pattern will help us to preserve the tuning which is made to the VO’s for better performance and will help us to separate the web service logic where we can have different tuning more suitable for the needs of the exposed web services.

In the “Facade” we aim to reuse code and to separate from the business logic that is why there are no entity objects. The view objects in the “Facade” do not expose the view objects from the library directly. They need to extend the view objects from the application module library or offer new view objects for operations that are accessible only for the web consumers and not from the web interface.

Way of implementation

There are two dominant styles of building a web service either with SOAP or REST. Currently, version 11g of JDeveloper offers a straightforward method for implementing SOAP web services from BC’s. If you want to use REST you have to build a large part of the code on your own, however in future releases of JDeveloper and ADF there will be REST support. In this post, we will focus on the SOAP style for exposing application module as web service.

  1. First we must create the ADF library from the existing application module in order to reuse the EO’s and VO’s in our web service part. We must ensure that we have a database connection and that the model project uses it.

    F mYyJ4Oy8h2y15gvxmz906UxyBTuTf K2h5r8z tw5Pl h6PLp5rHAhqRK9mUppnrg - Exposing Web Services From Business Components

  • After we are sure that we use the connection we must create a deployment profile for our ADF library.

    PV6E3HjVxHPykFph0k8 maI3wGnG90dnFNHSCbO65ZewjSxCMDXSg6lD4S JIHTjY0dhywyuHGBqC6q6 uYNy Arp7Qy4nnWehws2px9RmoyIG5 MVtJlA2ou eKhmuRbQDITRg - Exposing Web Services From Business Components

  • In the profile, we must ensure that all dependencies and connections are included.

    - Exposing Web Services From Business Components

  • We deploy the ADF library and then we create a new file system resource in the IDE from this .jar file.After we click “OK” button the resources should be available in the resource tab in JDeveloper.

    a27bG3OX33h9A3bDBm8wR9bL3N66Mm053FJnsrkw 9b0wbNYG8kSWexqfEZT0hBfPN80I hbZE7lZW01fD5 7k Mj64 XsVcheqZ5jsiZfln2Z34AQJRpGKbFB - Exposing Web Services From Business Components

    2.  Creating the service project. For this project, we will use generic project and we will add Business Components, Web Service and XML technologies in it.

    vl2UJa0 F9P5AAW2NObTF8GwdtN1mfTWRgVAJ013lHWNYTmCwRbxF3hXfKM3Cppqqq4CydR9iUjinmtUz6J - Exposing Web Services From Business Components

  • After we created the project we must include the already created ADF library in it, so we can reuse the existing Business Components.

    - Exposing Web Services From Business Components

  • When the library is included we must provide a password for the connection because it is not stored in the jar file for security reasons.Also, make sure that the new project uses the connection. This can be observed in the project properties under Business Component

bm2AkGX60wnB4az24LIxsgMXIjlkmw sZ9YlDEQ7FmV0BTwLD5oGYegUR 8kAucpZrOrBm j0vEv 5MxV raq6GbHMDtcURCwOfux3swSxlIXZrSkVVeJXLnJgrIKNaWM AnOEA - Exposing Web Services From Business Components

  • After all these steps are done we can create the needed view objects by extending the ones in the ADF library. If we create new business logic then we create new view objects based on the entities from the ADF library.

    - Exposing Web Services From Business Components

  • Then we can create the SDO objects for the VO’s that we added.However, this step can be committed because when adding the VO’s to exposed application module these files will be created automatically.

  • The application module, in this case, is the web service endpoint. And we can group the view objects in different application modules according to their functional fitness. For these application modules, we can have different fine tuning. To expose the application module as web service, we must go to service interface tab and click the green plus. From there we can choose which view objects to be included and we can create meaningful names for their methods.

    Lwr4p0d 2gyp906yEdlDfk9KhYvfFhwoc8K9IMXg3bMXp4Uf zMir7stU2xI56KAbgIRtVKp6t0505PJmHA88rEoYFCVKfyaDwn6rco3xMJXOHUGj WlDXoU4njnLnm7uePlSu8 - Exposing Web Services From Business Components

    7fqp9jTi33d5ghDwXqc35XOUzLcyWcpLH7JuoKciOauq1l8A2bQsiKlVwy2XXxMMm - Exposing Web Services From Business Components

  • The only thing left is to create a deployment profile for the exposed web service module. Here we must choose business components service interface.

    wjPfKRcjlj2bC8CrOW tvIjtYtMrRg0RULEVFFenAnD2bt B cBabIc r 60OmVniffKIwVjbfXLIO99xCqOmgxv2SKJVN tPLIuj4tdpBuLaHKA1aluVT6FgY5vJP1OKoqsWcg - Exposing Web Services From Business Components

  • We can customize the URL of the web service from the project properties this is the context-root of the Java EE application.

    - Exposing Web Services From Business Components

 

I plane to post a blog about Creating custom web services from application module which will be linked with 642-414 Exam

 

Java EE and Oracle Developer at Dreamix