Saturday 20 August 2022

Sample JAX-RS REST API Implementation

 We can use different  tools and technologies to create and expose a REST API. In this blog I will explain how to create a simple JAX-RS REST API using JDeveloper. 

  • Open Jdeveloper and create a new ADF REST Web Application
  • Provide an application name - JaxRsSampleApp
  • Provide a package name - xxvk.svn
  • Select Next and Keep the default Project Name 
  • Select Finish
  • This will generate two projects. 
    • RESTModel
    • RESTWebservice
  • Delete the RESTModel project
  • Right click the RESTWebservice project and select new
  • Select Java Class and provide a name. - HelloService
  • Add following  @Path("/services") before the class definition // Note : Path can be anything
  • Select the warning/error next to Path and select add JaxRs package to the project. 
  • As soon as you add the JAX RS package to the project it will generate the main application Java class - GenericApplication with an extend jax.rs.core.Application
  • Delete the default method and add the following sample method to return sample plain text. 
  • Right click the project and select project properties
    • Got to Java EE Application
    • Context Root to a meaning full value. -- HelloService
  • Save changes 
  • Right click the Java service and select RUN. 
  • This will deploy the application to Integrated server and provide the sample URL
    • http://127.0.0.1:7101/xxvk-service/resources/services
  • Take the URL and paste in a browser. It will display the result. 
    package xxvk.svn;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.MediaType;

@Path("/services")
public class HelloService {
        @GET  // This will import the Get package
        @Produces(MediaType.TEXT_PLAIN)  // This will produce the out put in plain text format
        public String Sayhello(){
            return "Hello Welcome";
        }
}






Friday 19 August 2022

SOA - Receive Message From EJB

 We can use EJB service to receive message from locally deployed EJB applications. We can use the following steps to create a SOA application to consume message from an EJB.

  • Create a SOA application 
  • Create an empty SOA project
  • Select the SOA project created above , right click and select New option 
  • Select Java class and provide class name and package name and select ok
  • If you get a prompt to select the folder then select project_name/src folder
  • Overwrite the generated class with below sample interface code. 
        package svn.com.callback;
        import java.util.List;
        import svn.com.model.XxComStatus;  // POJO class representing incoming message structure.
        public interface class_name
            {
              public String exec(XxComStatus status);
            }

        • Go to SOA composite add select EJB service
        • Provide Service Name - ConsumeEJBMessage
        • Provide a meaningful JNDI Name - ConumeCallbackMessageEJB
        • Provide Java Interface Name as - svn.com.callback.class_name  // Taken from above Java code. 
        • Open the composite SOURCE tab and add the missing values. 
          <service name="ConsumeEJBMessage">
            <interface.java interface="svn.com.callback.class_name"/>
            <binding.ejb uri="ConumeCallbackMessageEJB" ejb-version="EJB3" javaInterface="svn.com.callback.class_name"/>
          </service>
        • Create a BPEL process without service definition
        • Now wire EJB service and BPEL. This will generate the service WSDL
        • Now you can update the SOA composite as per the business requirement. 


        Sample Composite:



        Reference : https://technology.amis.nl/it/publish-soa-composite-application-as-ejb-to-be-invoked-from-java-applications-using-ejb-binding/

        IDCS - Identity Federation with Azure and Google (SAML IDP & Social IDP)

          Collect IDCS Meta Data Enable "Access Signing Certificate" option to get the IDCS metadata.   Default Domain Settings ->  Sel...