try {
if (serviceURL.startsWith("https")) {
boolean useHostKey = true;
if (globalConfiguration == null) {
throw new XregistryException(
"To make Secure WSIF client Global configuration must nor be Null");
}
SoapHttpDynamicInfosetInvoker invoker = createSecureInvoker(globalConfiguration,
useHostKey);
String wsdlAsStr = invoker.invokeHttpGet(serviceURL);
// System.out.println(wsdlAsStr);
XmlElement el = XmlConstants.BUILDER
.parseFragmentFromReader(new StringReader(wsdlAsStr));
WsdlDefinitions def = new WsdlDefinitions(el);
WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
WSIFService serv = wsf.getService(def);
serv.addLocalProvider(new Provider(invoker));
client = XmlBeansWSIFRuntime.getDefault().newClientFor(serv.getPort());
((XsulSoapPort) client.getPort()).setInvoker(invoker);
// WsdlResolver wsdlResolver = WsdlResolver.getInstance();
// wsdlResolver.setSecureInvoker(invoker);
//
//// String wsdlAsStr = invoker.invokeHttpGet(serviceURL);
//// // System.out.println(wsdlAsStr);
//// XmlElement el = XmlConstants.BUILDER
//// .parseFragmentFromReader(new StringReader(wsdlAsStr));
//// WsdlDefinitions def = new WsdlDefinitions(el);
// WsdlDefinitions def = wsdlResolver.loadWsdl(new URI(serviceURL));
//
// WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
// WSIFService serv = wsf.getService(def);
// serv.addLocalProvider(new Provider(invoker));
// client = XmlBeansWSIFRuntime.getDefault().newClientFor(serv.getPort());
// ((XsulSoapPort) client.getPort()).setInvoker(invoker);
} else {
client = XmlBeansWSIFRuntime.newClient(serviceURL);
}
} catch (WSIFException e) {
throw new XregistryException(e);
} catch (XsulException e) {
throw new XregistryException(e);
} catch (XmlBuilderException e) {
throw new XregistryException(e);
} catch (IOException e) {
throw new XregistryException(e);
} catch (GeneralSecurityException e) {
throw new XregistryException(e);
} catch (GSSException e) {
throw new XregistryException(e);
}
return client;
}