Application Download: https://www.dropbox.com/s/s7csgy8svcij3aj/VerifyUserJson.zip
Use Case ScenarioI wanted to be able to invoke a REST service from an application (regardless of it being ADF Mobile, ADF portal, BPEL, or a standard HTML5 JQuery Mobile app). So I built the sample application (using JDev 18.104.22.168) as a JSON REST app using JAX-RS Jersey and standard J2EE. This was deployed to my standalone WebLogic 10.3.5 server. I created a standard J2EE mobile application (using JDev 22.214.171.124 … coming in PART II) to invoke and consume the REST service. Both were deployed to the same server so they could leverage the same domain name. I will discuss more about why they need to be on the same domain (in PART II when we build the mobile app).
Part I: VerifyUserJson AppIn JDev 126.96.36.199 they’ve built in support for REST Web Services projects. So we’ll go ahead and use this version of JDEV. We’re still able to package and deploy the application on a standard 10.3.5 instance of WebLogic because we include the .jar libs in our WEB-INF/lib folder (included in the sample app).
After that I created three Java classes (LoginRequest, LoginRequestHandler, and DataHandler).
- This java class has the main verifyLogin method which accepts a username and password as input parameters. It returns either true or false back to the calling method.
- This is method invokes the LoginRequest method and returns the response as plain/text. You can also return application/xml or application/json depending on how you want to display it in your application. I also used the GET HTTP method to retrieve the “stuff” from the resource.
- Method to get the connection to the ORACLE XE database for the HR Schema. You can change this to point to any database that has the HR SCHEMA.
1: <servlet> 2: <servlet-name>jersey</servlet-name> 3: <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 4: <load-on-startup>1</load-on-startup> 5: </servlet> 6: <servlet-mapping> 7: <servlet-name>jersey</servlet-name> 8: <url-pattern>/jersey/*</url-pattern> 9: </servlet-mapping>
I added these .jar libs to my WEB-INF/lib folder so that I don’t have to worry about matching any of the versions on the application server. Here is a list of the libs in the screenshot below. They are also attached to the code in this blog post. Your application structure should look similar to this: You can test the LoginRequest by running it locally in your JDev (main method) before you deploy it to your
After I deploy the application to server we can test it by invoking this URL with the appropriate parameters.
If you have any suggestions or comments please let me know.