One of the requirements of application deployment modules was to change import bindings when we deploy in different environment. Like if a BPM process is calling external services then the endpoint of these services need to change for every environment. Here is how you can change binding endpoint using wsadmin and jython:
#This will get you list of all SCA modules in the connected environment
scaModList=AdminTask.listSCAModules().split(System.getProperty('line.separator'))
#Now iterate through the SCA modules to get to he module you are interested in
for scaMod in scaModList:
scaModNames=scaMod.split(':')
scaImports = []
#This will get you list of all imports for the module
scaImports=AdminTask.listSCAImports("[-moduleName " +scaModNames[0] + "]").split(System.getProperty('line.separator'))
#Now iterate through all imports to get to the import you are interested in
for scaImport in scaImports:
#Now get the actual binding
binding=AdminTask.showSCAImportBinding("[-moduleName " +scaModNames[0] + " -import " +scaImport + "]")
# Check if binding is actually webservices binding
if binding.find ("WsImportBinding")!=-1:
bindingAtr=binding.split(',')
# Check if the binding is the one you want to change
if bindingAtr[0].find("yourBinding Name"):
#change the binding
AdminTask.modifySCAImportWSBinding("[-moduleName " +scaModNames[0] +" -import " + scaImport + " -endpoint " + YourNewBindingEndPoint+ " ]")
Again its just an example and you probably want to check lot many exception situations like index is correct for all split output etc. The idea is to list all the commands you need to change the binding endpoint and you can probably build your application logic around it
Showing posts with label Websphere Process Server. Show all posts
Showing posts with label Websphere Process Server. Show all posts
Wednesday, 24 November 2010
Use java XML Dom parser in wsadmin jython
With my Application deployment module I had to read lot many xml files for different elements/attributes and I was first tag based parsing as I thought DOM will be very costly to use. But I soon realise that I need to work on many xml files and tag based parsing will mean a really stupid looking code. So I used Java dom parser in my jython and its really easy with jython wsadmin and java. I am not posting my complete class I am using to parse different xml files but if you want to do it, here is how you can get started:
import javax.xml.parsers.DocumentBuilderFactory as DocumentBuilderFactory
import javax.xml.parsers.DocumentBuilder as DocumentBuilder
dbf = DocumentBuilderFactory.newInstance()
db = dbf.newDocumentBuilder()
dom = db.parse("\usr\xml\app.xml")
docEle = dom.getDocumentElement()
attr= docEle.getAttribute("name")
print attr
Here I am printing attribute of root element of the xml I have read. You can look at java docs for complete set of methods available with dom parser
import javax.xml.parsers.DocumentBuilderFactory as DocumentBuilderFactory
import javax.xml.parsers.DocumentBuilder as DocumentBuilder
dbf = DocumentBuilderFactory.newInstance()
db = dbf.newDocumentBuilder()
dom = db.parse("\usr\xml\app.xml")
docEle = dom.getDocumentElement()
attr= docEle.getAttribute("name")
print attr
Here I am printing attribute of root element of the xml I have read. You can look at java docs for complete set of methods available with dom parser
Labels:
Application,
DocumentBuilderFactory,
dom,
java,
jython,
parser,
python,
Websphere,
Websphere Process Server,
wsadmin,
xml
Friday, 15 October 2010
IPC_CONNECTOR_ADDRESS in Websphere Process Server 7.0
Apparently there is a bug in Websphere Process Server 7.0 which can make your server environment unstable. Our problem was more around response time of Business Space. The bug rleates to default IPC_CONNECTOR_ADDRESS port which doesn't get define if you have created your servers with manageprofile command or used deployment environment to create servers. You will need manually define the port. Below is the command to create the port defination.
*Note change the port value if there is a conflict :)
AdminConfig.create('EndPoint', AdminConfig.create('NamedEndPoint',serverEntry , '[[endPointName "IPC_CONNECTOR_ADDRESS"]]'), '[[port "9633"] [host "localhost"]]')
*Note serverEntry is list of servers in a given node. You can get list of servers like this:
AdminConfig.list('ServerEntry', AdminConfig.getid( '/Cell:%s/Node:%s/' % ( AdminControl.getCell(), <Name_OF_Your_Node>) )).split(java.lang.System.getProperty('line.separator'))
*Note the above command also returns nodeAgent on the given node which should have IPC port already defined so do not run it for you NodeAgent
*Note change the port value if there is a conflict :)
AdminConfig.create('EndPoint', AdminConfig.create('NamedEndPoint',serverEntry , '[[endPointName "IPC_CONNECTOR_ADDRESS"]]'), '[[port "9633"] [host "localhost"]]')
*Note serverEntry is list of servers in a given node. You can get list of servers like this:
AdminConfig.list('ServerEntry', AdminConfig.getid( '/Cell:%s/Node:%s/' % ( AdminControl.getCell(), <Name_OF_Your_Node>) )).split(java.lang.System.getProperty('line.separator'))
*Note the above command also returns nodeAgent on the given node which should have IPC port already defined so do not run it for you NodeAgent
Turning off default_host with Websphere Process Server 7.0
Its always a good practice to turn off default host on Websphere application server if you are using http server. To do this you need to remove all the ports other then <Ip/SystemName:443 or 80>. If a request is made to the server then actual request address is preserved in HTTP headers and its used by container to resolve to a host. This secure you from any one trying to access your assets directly to websphere environment and every thing has to be routed to webserver first. But with Websphere Process server there is an internal application call Remote Application Loader (RemoteAL) deployed on each cluster (considering you are running a cluster topology). This application is accessed by contaners on <virtualHost>:9443 and I have still not figured how to change the container settings to point it to my webserver URL. The container always call the application local to the server container itself is running so we do not have to worry about load balancing or high availability the containers access is managed via webserver. But this leaves with one problem to leave default_host port 9443 but that would have meant other application bound to default_host can still be accessed directly. So we cared another virtual host by name RAL_HOST with 9443 and 443 port and bound RemoteAL application (on each cluster) to this host and left all other application bound to default_host which had 0nly 443 port.
It will be good to figure out how to route this call via webserver even if its not a requirement which is something I am currently working on.
It will be good to figure out how to route this call via webserver even if its not a requirement which is something I am currently working on.
Labels:
default_host,
HTTP Server,
RemoteAL,
Websphere,
Websphere Process Server
Subscribe to:
Posts (Atom)