return null;
}
public Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint) {
WSDLEndpoint wsdlEndpoint = new WSDLEndpoint();
if (!anonymousEndpoint) {
OMAttribute name = epConfig.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name != null) {
wsdlEndpoint.setName(name.getAttributeValue());
}
}
OMElement wsdlElement = epConfig.getFirstChildWithName
(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "wsdl"));
if (wsdlElement != null) {
// set the suspend on fail duration.
OMElement suspendElement = wsdlElement.getFirstChildWithName(new QName(
SynapseConstants.SYNAPSE_NAMESPACE,
org.apache.synapse.config.xml.XMLConfigConstants.SUSPEND_DURATION_ON_FAILURE));
if (suspendElement != null) {
String suspend = suspendElement.getText();
try {
if (suspend != null) {
long suspendDuration = Long.parseLong(suspend.trim());
wsdlEndpoint.setSuspendOnFailDuration(suspendDuration * 1000);
}
} catch (NumberFormatException e) {
handleException("suspendDurationOnFailure should be valid number.");
}
}
EndpointDefinition endpoint = null;
// get the service name and port name. at this point we should not worry about the presence
// of those parameters. they are handled by corresponding WSDL builders.
String serviceName = wsdlElement.getAttributeValue
(new QName(org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE,"service"));
String portName = wsdlElement.getAttributeValue
(new QName(org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE,"port"));
// check if wsdl is supplied as a URI
String wsdlURI = wsdlElement.getAttributeValue
(new QName(org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE,"uri"));
// set serviceName and portName in the endpoint. it does not matter if these are
// null at this point. we are setting them only for serialization purpose.
wsdlEndpoint.setServiceName(serviceName);
wsdlEndpoint.setPortName(portName);
if (wsdlURI != null) {
wsdlEndpoint.setWsdlURI(wsdlURI.trim());
try {
OMElement wsdlOM = SynapseConfigUtils.getOMElementFromURL(
new URL(wsdlURI).toString());
if (wsdlOM != null) {
OMNamespace ns = wsdlOM.getNamespace();
if (ns != null) {
String nsUri = wsdlOM.getNamespace().getNamespaceURI();
if (org.apache.axis2.namespace.Constants.NS_URI_WSDL11.equals(nsUri)) {
endpoint = new WSDL11EndpointBuilder().
createEndpointDefinitionFromWSDL(wsdlOM, serviceName, portName);
} else if (WSDL2Constants.WSDL_NAMESPACE.equals(nsUri)) {
//endpoint = new WSDL20EndpointBuilder().
// createEndpointDefinitionFromWSDL(wsdlURI, serviceName, portName);
handleException("WSDL 2.0 Endpoints are currently not supported");
}
}
}
} catch (Exception e) {
handleException("Couldn't create endpoint from the given WSDL URI : "
+ e.getMessage(), e);
}
}
// check if the wsdl 1.1 document is suppled inline
OMElement definitionElement = wsdlElement.getFirstChildWithName
(new QName(org.apache.axis2.namespace.Constants.NS_URI_WSDL11, "definitions"));
if (endpoint == null && definitionElement != null) {
wsdlEndpoint.setWsdlDoc(definitionElement);
endpoint = new WSDL11EndpointBuilder().
createEndpointDefinitionFromWSDL(definitionElement, serviceName, portName);
}
// check if a wsdl 2.0 document is supplied inline
OMElement descriptionElement = wsdlElement.getFirstChildWithName
(new QName(org.apache.axis2.namespace.Constants.NS_URI_WSDL11, "description"));
if (endpoint == null && descriptionElement != null) {
wsdlEndpoint.setWsdlDoc(descriptionElement);
handleException("WSDL 2.0 Endpoints are currently not supported.");
}
if (endpoint != null) {
// for now, QOS information has to be provided explicitly.
extractQOSInformation(endpoint, wsdlElement);
OMAttribute statistics = epConfig.getAttribute(
new QName(org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE,
org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_ATTRIB_NAME));
if (statistics != null) {
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if (org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_ENABLE.equals(
statisticsValue)) {
endpoint.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_ON);
} else if (org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_DISABLE.equals(
statisticsValue)) {
endpoint.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
}
}
}
wsdlEndpoint.setEndpoint(endpoint);
} else {
handleException("WSDL is not specified for WSDL endpoint.");
}
}