Methods Summary |
---|
private void | checkWsdlImports(org.w3c.dom.Node wsdl)
final NodeList kids = wsdl.getChildNodes();
for (int i=0; i<kids.getLength(); i++) {
final Node importNode = kids.item(i);
if (importNode.getLocalName() != null &&
importNode.getLocalName().equals("import")) {
final Node location =
importNode.getAttributes().getNamedItem(LOCATION);
if (location == null) {
importsToPatch.add(importNode);
}
}
}
|
private javax.xml.transform.Source | createSource(com.sun.xml.ws.mex.client.schema.MetadataSection section, java.lang.String identifier)
final Node node = (Node) section.getAny();
String sysId = identifier;
if (section.getDialect().equals(WSDL_DIALECT)) {
final String targetNamespace = getNamespaceFromNode(node);
if (sysId == null) {
sysId = targetNamespace;
}
nsToSysIdMap.put(targetNamespace, sysId);
checkWsdlImports(node);
} else {
if (sysId == null) {
sysId = getNamespaceFromNode(node);
}
}
final Source source = new DOMSource(node);
source.setSystemId(sysId);
return source;
|
private java.lang.String | getNamespaceFromNode(org.w3c.dom.Node node)
final Node namespace = node.getAttributes().getNamedItem("targetNamespace");
if (namespace == null) {
// bug in the server? want to avoid NPE if so
logger.warning(
MessagesMessages.MEX_0003_UNKNOWN_WSDL_NAMESPACE(
node.getNodeName()));
return null;
}
return namespace.getNodeValue();
|
public java.util.List | getSchemas()
return schemas;
|
private javax.xml.transform.Source | getSourceFromLocation(java.lang.String address, java.lang.String identifier)
try {
final HttpPoster poster = new HttpPoster();
final InputStream response = poster.makeGetCall(address);
if (identifier != null) {
final StreamSource source = new StreamSource(response);
source.setSystemId(identifier);
return source;
}
return parseAndConvertStream(address, response);
} catch (IOException ioe) {
final String exceptionMessage =
MessagesMessages.MEX_0014_RETRIEVAL_FROM_ADDRESS_FAILURE(
address);
logger.log(Level.SEVERE, exceptionMessage, ioe);
throw new WebServiceException(exceptionMessage, ioe);
}
|
public java.util.List | getWSDLs()
return wsdls;
|
private void | handleLocation(com.sun.xml.ws.mex.client.schema.MetadataSection section)
final String location = section.getLocation();
final String dialect = section.getDialect();
final String identifier = section.getIdentifier();
if (dialect.equals(WSDL_DIALECT)) {
wsdls.add(getSourceFromLocation(location, identifier));
} else if (dialect.equals(SCHEMA_DIALECT)) {
schemas.add(getSourceFromLocation(location, identifier));
} else {
logger.warning(
MessagesMessages.MEX_0002_UNKNOWN_DIALECT_WITH_ID(
dialect, identifier));
}
|
private void | handleReference(com.sun.xml.ws.mex.client.schema.MetadataSection section)
final MetadataReference ref = section.getMetadataReference();
populateLists(new MetadataClient().retrieveMetadata(ref));
|
private void | handleXml(com.sun.xml.ws.mex.client.schema.MetadataSection section)
final String dialect = section.getDialect();
final String identifier = section.getIdentifier();
if (dialect.equals(WSDL_DIALECT)) {
wsdls.add(createSource(section, identifier));
} else if (dialect.equals(SCHEMA_DIALECT)) {
schemas.add(createSource(section, identifier));
} else {
logger.warning(
MessagesMessages.MEX_0002_UNKNOWN_DIALECT_WITH_ID(
dialect, identifier));
}
|
private javax.xml.transform.Source | parseAndConvertStream(java.lang.String address, java.io.InputStream stream)
try {
final Transformer xFormer =
TransformerFactory.newInstance().newTransformer();
Source source = new StreamSource(stream);
final DOMResult result = new DOMResult();
xFormer.transform(source, result);
final Node wsdlDoc = result.getNode();
source = new DOMSource(wsdlDoc);
source.setSystemId(getNamespaceFromNode(wsdlDoc.getFirstChild()));
return source;
} catch (TransformerException te) {
final String exceptionMessage =
MessagesMessages.MEX_0004_TRANSFORMING_FAILURE(address);
logger.log(Level.SEVERE, exceptionMessage, te);
throw new WebServiceException(exceptionMessage, te);
}
|
private void | patchImports()
for (Node importNode : importsToPatch) {
final NamedNodeMap atts = importNode.getAttributes();
final String targetNamespace =
atts.getNamedItem(NAMESPACE).getNodeValue();
final String sysId = nsToSysIdMap.get(targetNamespace);
if (sysId == null) {
logger.warning(
MessagesMessages.MEX_0005_WSDL_NOT_FOUND_WITH_NAMESPACE(
targetNamespace));
continue;
}
final Attr locationAtt =
importNode.getOwnerDocument().createAttribute(LOCATION);
locationAtt.setValue(sysId);
atts.setNamedItem(locationAtt);
}
|
private void | populateLists(com.sun.xml.ws.mex.client.schema.Metadata mData)
for (MetadataSection section : mData.getMetadataSection()) {
if (section.getMetadataReference() != null) {
handleReference(section);
} else if (section.getLocation() != null) {
handleLocation(section);
} else {
handleXml(section);
}
}
|