logger.finest("called with handle: " + handle);
long start = System.currentTimeMillis();
// Initialize the return value
XCATPort reference = null;
// check to see if this service exists in the same address space
if (LocalServiceRegistry.containsService(handle))
reference = (XCATPort) LocalServiceRegistry.getServiceImpl(handle);
else {
// make sure the handleResolver exists
if (handleResolverURL == null)
throw new NonstandardException("Unable to locate a Handle Resolver implementation");
// Use the real HandleResolver to get a reference
LocatorType portLocator = null;
try {
portLocator = ClientUtil.findByHandle(handleResolverURL,
handle);
} catch (Exception e) {
logger.severe("Exception while trying to find a Reference via Handle",
e);
throw new NonstandardException("Exception while trying to find a Reference via Handle",
e);
}
ReferenceType[] portRef = portLocator.getReferenceArray();
if (portRef.length > 0) {
String portGSR = XmlUtil.getChildOf(portRef[0]);
if (portGSR != null) {
try {
// reference = (XCATPort) WSDLUtil.convertWSDLToRef(portGSR);
reference =
(XCATPort) SoapServices.getDefault().createStartpointFromXml(portGSR);
} catch (Exception e) {
// logger.severe("Can not convert WSDL to XSOAP Reference", e);
// throw new NonstandardException("Can not convert WSDL to XSOAP Reference",
// e);
logger.severe("Can not convert stringified reference to XCATPort", e);
throw new NonstandardException("Can not convert stringified reference to XCATPort",
e);
}
} else {
logger.severe("Reference for " + handle +
" found to be null");
throw new NonstandardException("Reference for " + handle +
" found to be null");
}
} else {
logger.severe("No reference found for " + handle +
" in Resolver: " + handleResolverURL);
throw new NonstandardException("No reference found for " + handle +
" in Resolver: " + handleResolverURL);
}
}
// check if the returned object has the expected interface
logger.finest("Returned class: " + reference.getClass().getName());
try {
if (!(Class.forName(intfClassName).isAssignableFrom(reference.getClass())))
throw new NonstandardException("Returned reference is not an instance of " +
intfClassName);
} catch (ClassNotFoundException cnfe) {
logger.severe("Can't verify if returned class conforms to specified interface",
cnfe);