try {
for (int i = 0; i < scopes.length; i++) {
uriScopes[i] = new URI(scopes[i]);
}
DiscoveryClient discoveryClient = new DiscoveryClient(messageContext.getConfigurationContext(), discoveryProxy);
TargetService[] targetServices = discoveryClient.probe(types, uriScopes);
if ((targetServices != null) && (targetServices.length > 0)) {
// currently we try to use the first one.
URI targetURI = null;
if ((targetServices[0].getXAddresses() != null) && (targetServices[0].getXAddresses().length > 0)) {
targetURI = getTargetURI(targetServices[0].getXAddresses(),
(String) messageContext.getProperty(DiscoveryConstants.DISCOVERY_SCHEME));
} else {
// get the epr using a resolve request
TargetService targetService = discoveryClient.resolve(targetServices[0].getEpr().getAddress());
if ((targetService.getXAddresses() != null) && (targetService.getXAddresses().length > 0)) {
targetURI = getTargetURI(targetService.getXAddresses(),
(String) messageContext.getProperty(DiscoveryConstants.DISCOVERY_SCHEME));
} else {
throw new AxisFault("Resolve message did not return the service location");