Pages

Tuesday, September 4, 2012

How to modify end point URL's in an ADF/WebCenter application

Developers might have came across situations where they need to modify WSDL end point URL's, some properties or constants pertaining to a server before deploying their ADF/WebCenter application on different servers. Modifying these every time before deployment is a pain. So there should be some repository where you can define all these end point urls and properties, OR some mechanism such that the deployment process takes care of pointing to correct end point url's and properties before deploying on respective server.

There are many ways to achieve this. I will describe a few, which I implemented in some of my projects.
1. Deploying a .properties file as shared library on respective servers
2. Using build.xml file to modify the properties/URL's before deployment
3. Reading the properties/URL's from a db table.

All the above implementations have their own pros and cons. In this blog I will describe how to use properties file to change the WSDL end point URLs. With my next blog I will describe how to read the properties from a db table.

Create a simple project in the application which will contain the properties file. The project structure is as shown: 



Create a properties file that contains all the properties pertaining to all the servers.



Create a WAR deployment profile for the project. WAR profile will be deployed as Shared Library on respective servers. Create a JAR profile as well for the project, for successful compilation of main application.

You need to create and set MANIFEST.MF file to describe the above shared library. 


Sample MANIFEST.MF file with shared library name: WrsTsrMgrSharedProbLib


While deploying this WAR package, select Deploy as a shared Library option.


After successful deployment, you can see shared library WrsTsrMgrSharedProbLib under deployments.


Add the JAR created above in the main application for its successful compilation. However, this jar should not be packaged inside EAR archive during deployment. For this, uncheck it from WAR contributors of the main application as shown.



One last configuration required in main application is to register the shared library in the weblogic.xml file. This will allow the consuming applications to access the properties file at run time.




 You can access the properties file as below to change the end point URL in service.java file.



Where getProperty method(defined in an utility class, PropertiesUtil) is:


Developers need to deploy the properties file once before deploying the main application on respective servers. It is not required to deploy the shared library always before the main application deployment, unless and until any property is changed. However, if the shared library has to be deployed, the main application should be brought down and started again to pick the latest changes.

Another approach to modify the end point urls or properties is to write a build script that should be ran before deployment. The build file will change all the properties appropriately using the Replace ant task.

2 comments:

  1. hi
    this is helpfull.but where are we reading those properties file in ADF application?till the deplying as shared library is cleraed,but how to we read those end point URLs to create datacontrol on it?which calss in ADF is responsible for the datacontrol connection ?
    Could you kindly elaborate in detial in this area?

    ReplyDelete
    Replies
    1. Sorry for late response.
      But we are not creating data control. If you see last snapshots, we are getting the end point URL's from PropertiesUtil file, which is an utility file. The code to get the property is also mentioned above. Please let me know if you still have any concerns.

      Thanks,
      Umesh

      Delete