/** Replace the address locations for a given port component.
*/
public static void replaceAddressLocation(ServerEndpointMetaData sepMetaData)
{
WSDLDefinitions wsdlDefinitions = sepMetaData.getServiceMetaData().getWsdlDefinitions();
QName portName = sepMetaData.getPortName();
boolean endpointFound = false;
for (WSDLService wsdlService : wsdlDefinitions.getServices())
{
for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints())
{
QName wsdlPortName = wsdlEndpoint.getName();
if (wsdlPortName.equals(portName))
{
endpointFound = true;
String orgAddress = wsdlEndpoint.getAddress();
String uriScheme = getUriScheme(orgAddress);
String transportGuarantee = sepMetaData.getTransportGuarantee();
if ("CONFIDENTIAL".equals(transportGuarantee))
uriScheme = "https";
String servicePath = sepMetaData.getContextRoot() + sepMetaData.getURLPattern();
String serviceEndpointURL = getServiceEndpointAddress(uriScheme, servicePath);
SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
ServerConfig config = spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
boolean alwaysModify = config.isModifySOAPAddress();
if (alwaysModify || uriScheme == null || orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0)
{
log.debug("Replace service endpoint address '" + orgAddress + "' with '" + serviceEndpointURL + "'");
wsdlEndpoint.setAddress(serviceEndpointURL);
sepMetaData.setEndpointAddress(serviceEndpointURL);
// modify the wsdl-1.1 definition
if (wsdlDefinitions.getWsdlOneOneDefinition() != null)
replaceWSDL11SOAPAddress(wsdlDefinitions, portName, serviceEndpointURL);
}
else
{
log.debug("Don't replace service endpoint address '" + orgAddress + "'");