Search This Blog

Simple Python Program to Write and read xml file

Simple Python Program to Write and read xml file
import os
import xml.dom.minidom

dirs = os.listdir()
ListofFileNames = []
for filename in dirs:
  print ("List of files : ",filename)
  ListofFileNames.append(filename)

print("Files Names : ",ListofFileNames)
print("Current Dir : ",os.getcwd())

filecomposite= open("Composite.xml","w+")
filecontent ='<note><to>Tove</to><from id="12345">Jani</from><heading>Reminder</heading><body>Don forget me this weekend!</body></note>'
filecomposite.write(filecontent)
filecomposite.close()

f=open("Composite.xml", "r")
if f.mode == 'r':
  contents =f.read()
  print (" File contents  :  ",contents)

def readxmltags():
  doc = xml.dom.minidom.parse("Composite.xml")
  elementValues = doc.getElementsByTagName("from")

 
  for elementvalue in elementValues:
        print("I am inside method - From element value : ",elementvalue.firstChild.data)
        attributeValue = elementvalue.getAttribute("id")
        print("Attribute values : ",attributeValue)
readxmltags()




Output :

List of files :  Composite.xml
List of files :  .bash_logout
List of files :  .profile
List of files :  .bashrc
List of files :  .pylint.d
List of files :  _test_runner.py
Files Names :  ['Composite.xml', '.bash_logout', '.profile', '.bashrc', '.pylint.d', '_test_runner.py']
Current Dir :  /home/runner
 File contents  :   <note><to>Tove</to><from id="12345">Jani</from><heading>Reminder</heading><body>Don forget me this weekend!</body></note>
I am inside method - From element value :  Jani
Attribute values :  12345

Connecting from Weblogic server to JBoss server using Bridges - JMS Bridge Destinations

Connecting from Weblogic server to JBoss server using Bridges - JMS Bridge Destinations

List of required Jar Files Please in place server lib Folder

Base_Domain/lib

  




Click JMS Bridge Destinations



Create New and provide below information (Target System Jboss information)





Name:  ATGJbossJMSDestination
Adapter JNDI Name: eis.jms.WLSConnectionFactoryJNDIXA
Connection URL:   jnp://xyz:1099
Connection Factory JNDI Name: /ConnectionFactory
Destination JNDI Name:  queue/OrderCreateTest ( Only for Testing Purpose )
Initial Connection Factor: org.jnp.interfaces.NamingContextFactory (This Property is very important)




Click Ok.  ATGJbossJMSDestination created.

Source JMS Bridge Creation: (Weblogic Source System)


  


Name:  ATGInputSrc
Adapter JNDI Name: eis.jms.WLSConnectionFactoryJNDIXA
Connection URL:  t3://localhost:7001
Connection Factory JNDI Name:  jms.ATGInput_CF
Destination JNDI Name:  jms.ATGInput_Queue


Click ok.


ATGInputSrc created as shown above.

Create a New Bridge:


Select Source Destination   (Weblogic)



Select Message Provider  à weblogic Server 7.0 or higher



Select Target Bridge Destination: (JBoss)



Select Message Provider  à Other JMS



Select Server Name: (Please chose always SOA_Server) in this example shown AdminServer

















Bridge Creation Done :



Restart weblogic Server (Note: whenever changes made in source or target Bridge. Restart Server)
If you facing State as Inactive please check Target System (Jboss)




Correct Setting  TO Push Message
State: Active

Description : Forwarding Message  

Enabling JMS Server logs in Weblogic Server

Enabling JMS Server logs in Weblogic Server


Default the JMS Server log available in below location


     Enabling  log message in Topic level. If "All Body" option choose then complete message will be logged in JMS server logs.


JMS Server Log file location


Sample JMS Server logs will body content