Wednesday, January 30, 2013

WPS : Updating the Webservice URL by using Scripts : Jython Script

WSADMIN tool

The WebSphere Application Server wsadmin tool provides the ability to run scripts. The wsadmin tool supports a full range of product administrative activities  You can use the wsadmin tool to manage WebSphere Application Server as well as the configuration, application deployment, and server run-time operation
wsadmin tool supports a full range of product administrative activities. The wsadmin tool supports two scripting languages: Jacl and Jython. BUt Jacl has been depricated with the v6.1 relase of websphere and the recomended direction is to use jython. Five objects are available when you use scripts:
  • AdminControl: Use to run operational commands.
  • AdminConfig: Use to run configurational commands to create or modify WebSphere Application Server configurational elements.
  • AdminApp: Use to administer applications.
  • AdminTask: Use to run administrative commands.
  • Help: Use to obtain general help.  

To perform a task using scripting, you must first perform the following steps:

  1. Choose a scripting language. The wsadmin tool only supports Jacl and Jython scripting languages. Jacl is the language specified by default. If you want to use the Jython scripting language, use the -lang option or specify it in the wsadmin.properties file.
  2. Start the wsadmin scripting client interactively, as an individual command, in a script, or in a profile.
 The options for the wsadmin tool are case insensitive.

This will help us go create JNDI's for application, Updating the webservice URL's Creating or deleting Activation Specifications for our application on server and many more.. It will help us more..

** 1. I will tell u  how to use "AdminTask" for  updating the WSBinding URL using this script.

Syntax

AdminTask.modifySCAImportWSBinding('[-moduleName ' +<moduleName>+'-import ' + < import name> + ' -endpoint ' + <new url>+ '-applicationName ' + <applicationName> +'App]  ')

EX:
AdminTask.modifySCAImportWSBinding('[-moduleName ' + SampleWebserviceModule+'-import ' + TargetWebserviceImport + ' -endpoint ' +http://172.17.6.120:/DecisionService/DetermineService + '-applicationName ' + SampleWebserviceModuleApp]  ')

for saving these changes in server we should use  AdminConfig.save.

By using this code we can able to update the url of WSBining Import of any application.


** 2. I will tell u how to update JNDI of application by using AdminApp.

Syntax: AdminApp.edit('<ApplicationAppname>','[-BindJndiForEJBMessageBinding [[ ApplicationNameEJB.jar <port name of Export> ApplicationNameEJB.jar,META-INF/ejb-jar.xml "" <activation specification name> "" "" ]]]')

EX:
AdminApp.edit('SampleApplicationModuleApp','[-BindJndiForEJBMessageBinding [[ SampleApplicationModuleEJB.jar ChangeEventPort SampleApplicationModuleEJB.jar,META-INF/ejb-jar.xml "" jms/ChangeEventAllOperation_AS "" "" ]]]')
for saving these changes in server we should use  AdminConfig.save.


** 3. Code For Creating Queues
 Syntax:
AdminTask.createWMQQueue('qnode(cells/qcell/nades/qnode|node.xml)','[-name <jsmqueue name> -jndiName <queue jndi name> -queueName <wmqQueuename> -qmgr <queue Manager Name> - description ]')
Ex :
AdminTask.createWMQQueue('qnode(cells/qcell/nades/qnode|node.xml)','[-name jmsQueueName -jndiName jms/jmsQueueName -queueName MQQueueName -qmgr QMGR - description ]')


**4. Code For creating Connection Factory 
 Syntax:
AdminTask.createWMQConnectionFactory('qnode(cells/qcell/nades/qnode|node.xml)','[-type QCF -name <QCF name> -jndiName <queue ConnectionFactory jndi name> - description -qmgrName <WMQqueue Manager Name> -wmqTransportType BINDINGS_THEN_CLIENT -qmgeHostName <wmq Server Host Name> -qmgrPortNumber <WMQServicePort> -qmgrSvrconnChannel <ChannelName> ]')

EX:
AdminTask.createWMQConnectionFactory('qnode(cells/qcell/nades/qnode|node.xml)','[-type QCF -name <QCF name> -jndiName <queue ConnectionFactory jndi name> - description -qmgrName <WMQqueue Manager Name> -wmqTransportType BINDINGS_THEN_CLIENT -qmgeHostName <wmq Server Host Name> -qmgrPortNumber <WMQServicePort> -qmgrSvrconnChannel <ChannelName> ]')


Run This Code By Using "wsadmin" :


save this file as <filename>.py into \RootDirectory\InstallationPath\profiles\qbpmaps\bin


open command prompt
c:\>cd  \RootDirectory\InstallationPath\profiles\qbpmaps\bin
c: \ RootDirectory\InstallationPath\profiles\qbpmaps\bin> wsadmin.bat -lang jython -username admin -password admin -f <filename>.py

EX:
c: \ RootDirectory\InstallationPath\profiles\qbpmaps\bin> wsadmin.bat -lang jython -username admin -password admin -f URLUpdate.py

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.