Search This Blog

Monday, March 05, 2012

WLST SOA MBeans Examples

 

// Get the deployed Composites

connect('weblogic', 'Welcome1', 't3://localhost:7001')
domainRuntime()
soaBean = ObjectName('oracle.soa.config:Location=AdminServer,name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra')
print soaBean
composites = mbs.getAttribute(soaBean, 'DeployedComposites')
for composite in composites: 
print 'composite: ',composite 
disconnect()
exit()


// Change the Composite auditLevel to Development

print 'starting the script ....'
username = 'weblogic'
password = 'Welcome1'
url='t3://localhost:7001'

connect(username,password,url)

domainRuntime()

helloworldComposite = ObjectName('oracle.soa.config:Location=AdminServer,partition=default,j2eeType=SCAComposite,revision=1.0,label=soa_2073ceb3-d703-453f-8867-79d3b44d637c,Application=soa-infra,wsconfigtype=WebServicesConfig,name="File1"')
print helloworldComposite
params = ['auditLevel','Development']
sign = ['java.lang.String','java.lang.String']
mbs.invoke(helloworldComposite, 'setProperty', params, sign)
print mbs.getAttribute(helloworldComposite, 'Properties')
disconnect()
exit()
disconnect()
exit()


// Print the Composite Properties

print 'starting the script ....'
username = 'weblogic'
password = 'Welcome1'
url='t3://localhost:7001'

connect(username,password,url)

domainRuntime()

helloworldComposite = ObjectName('oracle.soa.config:SCAComposite.SCAService=Test1,name=AdapterBinding,revision=1.0,partition=default,SCAComposite="File1",Location=AdminServer,label=soa_2073ceb3-d703-453f-8867-79d3b44d637c,j2eeType=SCAComposite.SCAService.SCABinding,Application=soa-infra')
print helloworldComposite
print mbs.getAttribute(helloworldComposite, 'Properties')
disconnect()
exit()
disconnect()
exit()

// Change the ExcludeFiles property of the File Adapter

print 'starting the script ....'
username = 'weblogic'
password = 'Welcome1'
url='t3://localhost:7001'

connect(username,password,url)

domainRuntime()

helloworldComposite = ObjectName('oracle.soa.config:SCAComposite.SCAService=Test1,name=AdapterBinding,revision=1.0,partition=default,SCAComposite="File1",Location=AdminServer,label=soa_2073ceb3-d703-453f-8867-79d3b44d637c,j2eeType=SCAComposite.SCAService.SCABinding,Application=soa-infra')
print helloworldComposite
print '-----------Before Changes------------------'
print mbs.getAttribute(helloworldComposite, 'Properties')
params = ['ExcludeFiles','*.akshay*']
sign = ['java.lang.String','java.lang.String']
mbs.invoke(helloworldComposite, 'setStringProperty', params, sign)
print '-----------After Changes------------------'
print mbs.getAttribute(helloworldComposite, 'Properties')
disconnect()
exit()
disconnect()
exit()

// Display the MDS listPartitions

connect('weblogic', 'Welcome1', 't3://localhost:7001')
domainRuntime()

mdsBean = ObjectName('oracle.mds.lcm:name=MDSDomainRuntime,type=MDSDomainRuntime')

print 'invoke listRepositories without parameters on mds bean'
repositories = mbs.invoke(mdsBean, 'listRepositories',None,None)
for repository in repositories:
mdsObject = ObjectName(repository)
Name = mbs.getAttribute(mdsObject, 'Name')
print 'mds repository object: ', Name
params = [Name]
sign = ['java.lang.String']
partitions = mbs.invoke(mdsBean, "listPartitions", params, sign)
for partition in partitions:
   print 'partition: ', partition
disconnect()
exit()

4 comments:

Unknown said...

Hi Ravi, could you please let me know how to get Composite mode for a composite using WLST, i want to get a DN of a composite.

Unknown said...

Its great and very helpful info, Keep posting ravi.

sanjeev said...

I am getting the below error while trying to get the list of deployed composites.


wls:/soa_ite07_Domain/domainRuntime> print soaBean
oracle.soa.config:Location=soa_ite07_AdminServer01,name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra

wls:/soa_ite07_Domain/domainRuntime> composites = mbs.getAttribute(soaBean, 'DeployedComposites')
Traceback (innermost last):
File "", line 1, in ?
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
at javax.management.remote.rmi.RMIConnectionImpl_1036_WLStub.getAttribute(Unknown Source)
at weblogic.management.remote.common.RMIConnectionWrapper$12.run(ClientProviderBase.java:768)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.security.Security.runAs(Security.java:61)
at weblogic.management.remote.common.RMIConnectionWrapper.getAttribute(ClientProviderBase.java:766)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:878)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

javax.management.InstanceNotFoundException: javax.management.InstanceNotFoundException: oracle.soa.config:name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra

Rohit said...

i am using below code

domainRuntime()
soaBean = ObjectName('oracle.soa.config:Location=AdminServer,name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra')
print (soaBean)
composites = mbs.getAttribute(soaBean, 'DeployedComposites')
for composite in composites:
print ('composite: ',composite)


and getting below Error please suggest:
oracle.soa.config:Location=AdminServer,name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra
Problem invoking WLST - Traceback (innermost last):
File "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\readComposite.py", line 67, in ?
File "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\readComposite.py", line 40, in readComposite
javax.management.InstanceNotFoundException: oracle.soa.config:name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra
at weblogic.utils.StackTraceDisabled.unknownMethod()
Caused by: javax.management.InstanceNotFoundException: oracle.soa.config:name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra
... 1 more

javax.management.InstanceNotFoundException: javax.management.InstanceNotFoundException: oracle.soa.config:name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra



my composites are present in service-bus (AdminServer)