Friday, September 18, 2015

SOA MDS Repository

    Updating single files in the MDS Repository

SCA composites contain several metadata artefacts such as xsds ,wsdls, xslts and dvm files that should be stored in the Oracle metadata repository MDS. In order to do this, it is very common to generate a separate project for these artefacts and deploy it as a whole using JDeveloper directly or the ant commands. For time to time the question arises on how to update single files that are stored inside the repository without having to deploy the whole project.

Disclaimer

Only metadata files under the “apps” directory should be updated using the following procedure. Deployed composite files under the “deployed-composites” or “soa” directories should not be changed manually because it could damage the running instances and the correspondent deployments. In the worst cases, the domain can become unstable and unusable. Also, Oracle doesn’t support it.
Oracle provides a useful command called “importMetadata” that can be use to update one or more files. Lets take the following repository as an example
mdssinglefiles
In order to update a single file, lets say HRManagementService.wsdl, several task have to be executed
1.   Preparing the local environment
Updating the MDS is done using a WLST command. Therefore there has to be a JDeveloper  or a Weblogic installation in the local environment.
The same MDS path structure has to be created in the local system in order to update a specific file in the repository. In the sample MDS repository, this file is located under /apps/mdsstuff/wsdl. This means that this path has to exist somewhere in the local system (for example under ‘/Users/testuser/Documents/work/ mdsdemo/apps/ mdsstuff / wsdl’) and the new version of HRManagementService.wsdl has to be inside the wsdl folder.
2.   Packaging the files (only for remote updating)
Here is where things get trickier. The WLST command will work perfectly if it is executed where the Admin server is running. Single files can be referenced and uploaded to the MDS repository. When executed remotely (not where the Admin server is running), the file(s) that are going to be updated have to be packed in an archive file like a zip or a jar.
In a linux/unix system, this archive can be generated with the use of the “zip” command:
zip -r /tmp/MyDemos/mdsdemo/mds.jar apps -i *. wsdl
where:
  • /tmp/MyDemos/mdsdemo/can be any path. It is where the zip/jar archive is going to be created.
  • mds.jar is the name of the archive file.
  • apps is the apps directory where the files reside. For the previous example, the command zip has to be executed from the following directory ‘/Users/testuser/Documents/work/ mdsdemo’.
  • *.wsdl defines that  only files ending with .wsld are to be included in the archive.
In windows other utilities can be used such as winzip, 7zip and winrar. It is important to mention that the generated archive should only contain the files that are going to be update to the repository. All other files, including the hidden ones from SVN, CVS, DS_STORE or backup files, should not be added to the archive.
3.   Starting WLST and connecting to then target environment
Open a console and navigate to the following folder:  <MIDDLEWARE_HOME>/oracle_common/common/bin where MIDDLEWARE_HOME is the path in the local system where the Oracle Middleware products are installed (in Windows the default location is usually the following: C:\Oracle\Middleware)
In there execute the wlst application: wlst.cmd (or wlst.sh)
$ ./wlst.sh
Now connect to the admin server
wls:/offline> connect(‘user’,’password’,’t3://host:port’)
where:
  • user: assigned user with logging and deployment privileges or weblogic.
  • password:  the password of the user
  • host: host where the admin server is running.
  • port: listening port of the admin server
4.   Uploading the file
After having completed the steps above, the file(s) can be uploaded to the MDS. Here again, there is a difference between the local and the remote update. For local update use the following command:
importMetadata(application=’soa-infra’, server=’managedserver’, fromLocation=’path_to_file’, docs=’mds_files_to_update’);
where:
  • managedserver: name of the managed server  where the soa suite  is running.
  • path_to_file: path pointing to the location of the apps folder. For the previous sample it will be like this:  /Users/testuser/Documents/work/ mdsdemo.
  • mds_files_to_update: the mds path and name of the file that is going to be updated. For the example provided, the path looks like this: /apps/ mdsstuff / wsdl/ HRManagementService.wsdl
The command for the remote update is slightly different:
importMetadata(application=’soa-infra’, server=’managedserver’, fromLocation=’path_to_archivefile’, docs=’mds_files_to_update’, remote=’true’);
  • managedserver: name of the managed server  where the soa suite  is running.
  • path_to_file: path pointing to the direction of the archive file. The name of the file has to be also included. Sample: /tmp/MyDemos/mdsdemo/mds.jar.
  • mds_files_to_update: the mds path and name of the file that is going to be updated. Following the example of above, the path looks like this: /apps/ mdsstuff / wsdl/ HRManagementService.wsdl
  • remote: indicates that this is a remote update and should be set to true.
This command uploads the file and updates the MDS repository.

4 comments: