Introduction
Samples
To run the samples you need to configure the file settings.properties with the following
Creating Java client
Role Service
Step 2: Setting up the authentication
Step 3: Calling the webservice
The purpose of this document is to illustrate and provide a starting point to use web services exposed by Oracle Identity Analytics 11g. Apache CXF 2.6.1 is used to generate the wrapper libraries.
Build Library Setup
Build Library Setup
We also need a few jars to get everything compiled
Samples
To run the samples you need to configure the file settings.properties with the following
Property Name
|
Description
|
user
|
Username for connecting to OIA
|
password
|
Password for OIA user
|
wsdlurl
|
Address for WSDL file
|
Edit web.xml with the following changes.
c. Restart OIA.
Webservice Endpoints
For a server that is running on localhost with port 7001 we have four web service endpoints available. These four endpoints are
Creating Java client
We can easily call the web services by creating a java client for the above 4 endpoints. We will be using Apache CXF to build our client application. However there are other ways also like using Apache Axis 1.x and Apache Axis 2.x. Every framework has its own way to wrap the web service operations, which we will not be covering here.
With Apache CXF we have a neat little command line client wsdl2java which creates the java client classes for us. We created the clients for the above four web services as shown below
I first saved the WSDL document from the above URLs. Also since the default generation logic creates a rather weird data structure to use I have put in some customization in javabindings.xml which is specified during client generation.
Role Service
Javabindings.xml
Once this is done classes are created in the generated folder. Please note that I created separate java projects for each of the web service. If you do all of them in one project you would need to do some manual class changes.
I added some test code also, which I’ll explain below. The projects structure in my eclipse looks like:
Calling the webservice
Any operation that is to be requested needs authentication. The web service client classes do not have any in-built authentication wrappers built. Rather this functionality is present in Apache CXF’s classes. We will go step by step on how the client is created now.
Step 1: Getting the client instance
We have four endpoints, each of which has a different client class to start off with. Below is what we need to get started for User Service.
It will be similar for the other services, for audit we will get the AuditService and so on for the others.
Step 2: Setting up the authentication
As mentioned earlier we need to take help from Apache CXF’s classes to get the authentication working. We wrapped all this up in one method in the class Common.
Here we are doing two things:
1. Add logging by adding LoggingInInterceptor and LoggingOutInterceptor in the interceptor queue.
2. Add username/password for authentication by inserting a WSS4JInterceptor
1. Add logging by adding LoggingInInterceptor and LoggingOutInterceptor in the interceptor queue.
2. Add username/password for authentication by inserting a WSS4JInterceptor
The above code is how Apache CXF wants it, so more details on why and how on this can be found on Apache CXF’s website.
Step 3: Calling the webservice
Each webservice has different operations available. However the way of operating is similar. Shown below is the easiest method to call getVersion() which is present in all the webservices.
Hi are you there?
ReplyDelete