// ClassLoader
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
if (tcl == null)
tcl = this.getClass().getClassLoader();
ServiceFactory factory = ServiceFactory.newInstance();
javax.xml.rpc.Service service = null;
// Service Interface
RefAddr tmp = ref.get(ServiceRef.SERVICE_INTERFACE);
String serviceInterface = null;
if (tmp != null)
serviceInterface = (String) tmp.getContent();
// WSDL
tmp = ref.get(ServiceRef.WSDL);
String wsdlRefAddr = null;
if (tmp != null)
wsdlRefAddr = (String) tmp.getContent();
// PortComponent
Hashtable<String,QName> portComponentRef = new Hashtable<>();
// Create QName object
QName serviceQname = null;
tmp = ref.get(ServiceRef.SERVICE_LOCAL_PART);
if (tmp != null) {
String serviceLocalPart = (String) tmp.getContent();
tmp = ref.get(ServiceRef.SERVICE_NAMESPACE);
if (tmp == null) {
serviceQname = new QName(serviceLocalPart);
} else {
String serviceNamespace = (String) tmp.getContent();
serviceQname = new QName(serviceNamespace,
serviceLocalPart);
}
}
Class<?> serviceInterfaceClass = null;
// Create service object
if (serviceInterface == null) {
if (serviceQname == null) {
throw new NamingException
("Could not create service-ref instance");
}
try {
if (wsdlRefAddr == null) {
service = factory.createService( serviceQname );
} else {
service = factory.createService( new URL(wsdlRefAddr),
serviceQname );
}
} catch (Exception e) {
NamingException ex = new NamingException
("Could not create service");
ex.initCause(e);
throw ex;
}
} else {
// Loading service Interface
try {
serviceInterfaceClass = tcl.loadClass(serviceInterface);
} catch(ClassNotFoundException e) {
NamingException ex = new NamingException
("Could not load service Interface");
ex.initCause(e);
throw ex;
}
if (serviceInterfaceClass == null) {
throw new NamingException
("Could not load service Interface");
}
try {
if (wsdlRefAddr == null) {
if (!Service.class.isAssignableFrom(serviceInterfaceClass)) {
throw new NamingException
("service Interface should extend javax.xml.rpc.Service");
}
service = factory.loadService( serviceInterfaceClass );
} else {
service = factory.loadService( new URL(wsdlRefAddr),
serviceInterfaceClass,
new Properties() );
}
} catch (Exception e) {
NamingException ex = new NamingException