Transformer transformer = templates.newTransformer();
// WSDL is associated with webservice, but url is endpoint-specific,
// so let WebService choose which endpoint to use.
WebServiceEndpoint endpointForImport =
webService.pickEndpointForRelativeImports();
URL root= wsi.getWebServerRootURL(endpointForImport.isSecure());
URL finalWsdlUrl = endpointForImport.composeFinalWsdlUrl(root);
int wsdlImportNum = 0;
for(Iterator iter = wsdlRelativeImports.iterator(); iter.hasNext();){
Import next = (Import) iter.next();
transformer.setParameter
(WSDL_IMPORT_NAMESPACE_PARAM_NAME + wsdlImportNum,
next.getNamespace());
// Convert each relative import into an absolute import, using
// the final wsdl's Url as the context
URL relativeUrl = new URL(finalWsdlUrl, next.getLocation());
transformer.setParameter
(WSDL_IMPORT_LOCATION_PARAM_NAME + wsdlImportNum, relativeUrl);
wsdlImportNum++;
}
int schemaImportNum = 0;
for(Iterator iter = schemaRelativeImports.iterator(); iter.hasNext();){
Import next = (Import) iter.next();
transformer.setParameter
(SCHEMA_IMPORT_NAMESPACE_PARAM_NAME + schemaImportNum,
next.getNamespace());
// Convert each relative import into an absolute import, using
// the final wsdl's Url as the context
URL relativeUrl = new URL(finalWsdlUrl, next.getLocation());
transformer.setParameter
(SCHEMA_IMPORT_LOCATION_PARAM_NAME + schemaImportNum,
relativeUrl);
schemaImportNum++;
}
int wsdlIncludeNum = 0;
for(Iterator iter = wsdlIncludes.iterator(); iter.hasNext();){
Import next = (Import) iter.next();
URL relativeUrl = new URL(finalWsdlUrl, next.getLocation());
transformer.setParameter
(WSDL_INCLUDE_LOCATION_PARAM_NAME + wsdlIncludeNum, relativeUrl);
wsdlIncludeNum++;
}
int schemaIncludeNum = 0;
for(Iterator iter = schemaIncludes.iterator(); iter.hasNext();){
Import next = (Import) iter.next();
URL relativeUrl = new URL(finalWsdlUrl, next.getLocation());
transformer.setParameter
(SCHEMA_INCLUDE_LOCATION_PARAM_NAME + schemaIncludeNum,
relativeUrl);
schemaIncludeNum++;
}
int endpointNum = 0;
for(Iterator iter = endpointsCopy.iterator(); iter.hasNext();) {
WebServiceEndpoint next = (WebServiceEndpoint) iter.next();
// Get a URL for the root of the webserver, where the host portion
// is a canonical host name. Since this will be used to compose the
// endpoint address that is written into WSDL, it's better to use
// hostname as opposed to IP address.
// The protocol and port will be based on whether the endpoint
// has a transport guarantee of INTEGRAL or CONFIDENTIAL.
// If yes, https will be used. Otherwise, http will be used.
URL rootURL = wsi.getWebServerRootURL(next.isSecure());
URL actualAddress = next.composeEndpointAddress(rootURL);
transformer.setParameter(ENDPOINT_ADDRESS_PARAM_NAME + endpointNum,
actualAddress.toExternalForm());
String endpointType = next.implementedByEjbComponent() ?
"EJB" : "Servlet";
deploymentLogger.log(Level.INFO,
"enterprise.deployment.endpoint.registration",
new Object[] { endpointType,
next.getEndpointName(), actualAddress });
endpointNum++;
}
transformer.transform(XsltWsdlDocument, new StreamResult(outputStream));