This discussion is archived
2 Replies Latest reply: Mar 8, 2013 7:19 AM by fmc RSS

List Business Services Endpoints with WLST

fmc Newbie
Currently Being Moderated
Hi,

We're using OSB 11.1.1.3 and 11.1.1.6 in several environments.
We just need to use wlst scripting to keep track of all business services and their endpoint uri's automatically.
We tried using some old scripts but found out that they don't work on 11g installations:

We tried the following code:

connect('weblogic','oracle10','t3://soavm2:7001')
domainRuntime()

sessionName = "FindServicesSession" + str(System.currentTimeMillis())
sessionMBean = findService(SessionManagementMBean.NAME, SessionManagementMBean.TYPE)
sessionMBean.createSession(sessionName)
servConfMBean = findService(ServiceConfigurationMBean.NAME + "." + sessionName, ServiceConfigurationMBean.TYPE)
alsbCore = findService(ALSBConfigurationMBean.NAME, ALSBConfigurationMBean.TYPE)
allRefs=alsbCore.getRefs(Ref.DOMAIN)
for ref in allRefs:
typeId = ref.getTypeId()
if typeId == "BusinessService":
serviceDefinition = servConfMBean.getServiceDefinition(ref)
endpointConfigration = serviceDefinition.getEndpointConfig()
print endpointConfigration

We get a "AttributeError: 'NoneType' object has no attribute 'getServiceDefinition'" error. It seems that it is related to metalink note "How To Modify Service Configurations By OSB JMX API [ID 1431254.1]". However the code provided there is for java through jmx, does anybody has a working example of how to do that on wlst?
Thanks!
  • 1. Re: List Business Services Endpoints with WLST
    Marc Kelderman Newbie
    Currently Being Moderated
    same issue here. did you find a solutiuon?

    Issue is related to note ate Oracle Support:

    "How To Modify Service Configurations By OSB JMX API [ID 1431254.1]"

    Marc

    So the code will note work. NO Solution found (yet)

    Edited by: Marc Kelderman on 8-mrt-2013 5:07

    Edited by: Marc Kelderman on 8-mrt-2013 5:09
  • 2. Re: List Business Services Endpoints with WLST
    fmc Newbie
    Currently Being Moderated
    Hi Marc,
    What i found is that we can get list of business services URIs by consulting SERVICE_URI_TABLE...
    Here's a script that reads a parameter file (which can have multiple domains information) with connection info and then gets all services and prints a list of the service name and URI on a file for each domain...


    # params.txt format:
    # user,passwd,admin-url
    # Ej:
    # weblogic,weblogic1,t3://adminsoa:7001
    # weblogic,weblogic100,t3//adminsoa2:7001
    import wlstModule
    from com.bea.wli.sb.management.configuration import SessionManagementMBean
    from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
    from com.bea.wli.sb.management.configuration import BusinessServiceConfigurationMBean

    from com.bea.wli.sb.util import EnvValueTypes
    from com.bea.wli.config import Ref
    from com.bea.wli.sb.util import Refs
    from xml.dom.minidom import parseString

    f1 = open('/tmp/params.txt','r')
    for line in f1:
    spline=line.split(',')
    usr=spline[0]
    pwd=spline[1]
    url=spline[2].replace("\n","")

    try:
    connect(usr,pwd,url)
    domName=cmo.getName()
    domainRuntime()
    sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
    sessionName="WLSTSession"+ str(System.currentTimeMillis())
    sessionMBean.createSession(sessionName)
    alsbSession = findService(ALSBConfigurationMBean.NAME + "." + sessionName, ALSBConfigurationMBean.TYPE)
    alsbCore = findService(ALSBConfigurationMBean.NAME, ALSBConfigurationMBean.TYPE)
    allRefs=alsbCore.getRefs(Ref.DOMAIN)
    fileName='/tmp/'+domName+'_'+url.replace('t3://','').replace(':','')+'_BServicesLista.csv'
    f2 = open(fileName, 'w')
    f2.write('Name'+','+'URL'+'\n')
    for ref in allRefs:
    typeId = ref.getTypeId()
    if typeId == "BusinessService":
    name=ref.getFullName()
    uris=alsbSession.getEnvValue(ref, EnvValueTypes.SERVICE_URI_TABLE, None)
    xml=parseString(uris.toString())
    xmlTag = xml.getElementsByTagName('tran:URI')[0].toxml()
    xmlData=xmlTag.replace('<tran:URI>','').replace('</tran:URI>','')
    f2.write('\"'+name+'\"'+','+'\"'+xmlData+'\"'+'\n')
    f2.close()
    except Exception,e:
    print "Error trying to connect to " + url + 'Error: ' + str(e)
    f1.close()
    disconnect()

    It's been working for us so far...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points