import javax.xml.ws.BindingProvider;
import javax.xml.namespace.QName;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Map;
public void init(ServiceEndPointDescription serviceDescription) {
super.init(serviceDescription.getName(), (Map) null);
this.logger = Logger.getLogger(this.getClass());
String wsdlLocation = serviceDescription.getURL() + "?wsdl";
URL url = null;
try {
url = new URL(wsdlLocation);
} catch (MalformedURLException e) {
throw new ConfigRuntimeException(wsdlLocation + " is not a valid URL", e);
}
QName namespace = new QName("http://internal.soap.server.service.config.quantum.get.citi.com", "ConfigurationRetrievalService");
this.configRetrievalMgr = (new ConfigurationRetrievalService(url, namespace)).getConfigurationRetrievalServiceSOAP11PortHttp();
try {
// 1. Drop reflection. Use Java 16+ Pattern Matching to cast to the specification interface
if (this.configRetrievalMgr instanceof BindingProvider bindingProvider) {
// 2. Safely extract the standard public Request Context Map
Map<String, Object> requestContext = bindingProvider.getRequestContext();
String serviceURL = serviceDescription.getURL();
this.logger.info("Creating loadbalancer and setting binding to end-point[" + serviceURL + "]");
// 3. Set the endpoint property using the standard public specification constant
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceURL);
} else {
throw new ConfigRuntimeException("WebService client port does not implement BindingProvider");
}
} catch (Exception e) {
String msg = "Could NOT retrieve request context so we cannot dynamically set web service URL!!";
this.logger.warn(msg, e);
throw new ConfigRuntimeException(msg, e);
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)