Often we may find a need for publishing the endpoints of all your service to a new client. Instead of getting the end points for each and every service from em console a java class would do that job quickly.
Code
================
package test;
import java.util.Hashtable;
import java.util.UUID;
import java.util.List;
import javax.naming.Context;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.facade.Composite;
import oracle.soa.management.facade.Service;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.facade.ComponentInstance;
import oracle.fabric.common.NormalizedMessage;
import oracle.fabric.common.NormalizedMessageImpl;
import oracle.soa.management.util.CompositeInstanceFilter;
import oracle.soa.management.util.ComponentInstanceFilter;
import java.util.Map;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.Element;
import java.io.*;
import oracle.soa.management.CompositeDN;
import oracle.soa.management.facade.Component;
public class EndpointLister {
public EndpointLister() {
super();
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://localhost:8001/soa-infra");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "weblogic1");
jndiProps.put("dedicated.connection", "true");
Locator locator = null;
try {
// connect to the soa server
locator = LocatorFactory.createLocator(jndiProps);
// find composite
List composite = locator.listComposites();
for(int i=0;i<composite.size();i++){
CompositeDN lCompositeDN = (CompositeDN)composite.get(i);
Composite lComposite = locator.lookupComposite(lCompositeDN);
List lServices = lComposite.getServices();
for(int j=0;j<lServices.size();j++){
Service lService =(Service)lServices.get(j);
System.out.println(lService.getWSDLURL());
}
}
}
catch( Exception E){
E.printStackTrace();;
}
}
public static void main(String[] args) {
EndpointLister endpointLister = new EndpointLister();
}
}
Dependent Jars
===================
servers\soa_server1\tmp\_WL_user\soa-infra\ztorh\soa-infra-mgmt.jar
oracle_common\modules\oracle.fabriccommon_11.1.1\fabric-common.jar
wlserver_10.3\server\lib\weblogic.jar
oracle_common\modules\oracle.jrf_11.1.1\jrf-api.jar
Code
================
package test;
import java.util.Hashtable;
import java.util.UUID;
import java.util.List;
import javax.naming.Context;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.facade.Composite;
import oracle.soa.management.facade.Service;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.facade.ComponentInstance;
import oracle.fabric.common.NormalizedMessage;
import oracle.fabric.common.NormalizedMessageImpl;
import oracle.soa.management.util.CompositeInstanceFilter;
import oracle.soa.management.util.ComponentInstanceFilter;
import java.util.Map;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.Element;
import java.io.*;
import oracle.soa.management.CompositeDN;
import oracle.soa.management.facade.Component;
public class EndpointLister {
public EndpointLister() {
super();
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://localhost:8001/soa-infra");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "weblogic1");
jndiProps.put("dedicated.connection", "true");
Locator locator = null;
try {
// connect to the soa server
locator = LocatorFactory.createLocator(jndiProps);
// find composite
List composite = locator.listComposites();
for(int i=0;i<composite.size();i++){
CompositeDN lCompositeDN = (CompositeDN)composite.get(i);
Composite lComposite = locator.lookupComposite(lCompositeDN);
List lServices = lComposite.getServices();
for(int j=0;j<lServices.size();j++){
Service lService =(Service)lServices.get(j);
System.out.println(lService.getWSDLURL());
}
}
}
catch( Exception E){
E.printStackTrace();;
}
}
public static void main(String[] args) {
EndpointLister endpointLister = new EndpointLister();
}
}
Dependent Jars
===================
servers\soa_server1\tmp\_WL_user\soa-infra\ztorh\soa-infra-mgmt.jar
oracle_common\modules\oracle.fabriccommon_11.1.1\fabric-common.jar
wlserver_10.3\server\lib\weblogic.jar
oracle_common\modules\oracle.jrf_11.1.1\jrf-api.jar
Your post is amazing. From long time I search for this information. But I didn’t get right thing. Thanks to you I got stuff which I am looking for. I would like to read more from you.
ReplyDeleteGround Penetrating Radar