Author: hiranya
Date: Tue Jan 25 14:17:10 2011
New Revision: 1063292

URL: http://svn.apache.org/viewvc?rev=1063292&view=rev
Log:
Making it possible prevent the WSDL endpoint factory from trying to parse the 
WSDL when constructing WSDL endpoints. Sometimes it is necessary for high level 
applications to simply construct the WSDLEndpoint object out of an XML 
configuration without loading the actual WSDL. In some scenarios the referenced 
WSDL may be off-line. Now this can be achieved by setting a special property 
for the WSDLEndpointFactory.


Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/WSDLEndpointFactory.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/WSDLEndpointFactory.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/WSDLEndpointFactory.java?rev=1063292&r1=1063291&r2=1063292&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/WSDLEndpointFactory.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/WSDLEndpointFactory.java
 Tue Jan 25 14:17:10 2011
@@ -24,6 +24,7 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.synapse.SynapseConstants;
 import org.apache.synapse.config.SynapseConfigUtils;
 import org.apache.synapse.config.xml.endpoints.utils.WSDL11EndpointBuilder;
@@ -68,6 +69,8 @@ import java.util.Properties;
  */
 public class WSDLEndpointFactory extends DefaultEndpointFactory {
 
+    public static final String SKIP_WSDL_PARSING = "skip.wsdl.parsing";
+
     private static WSDLEndpointFactory instance = new WSDLEndpointFactory();
 
     private WSDLEndpointFactory() {
@@ -106,35 +109,40 @@ public class WSDLEndpointFactory extends
             wsdlEndpoint.setServiceName(serviceName);
             wsdlEndpoint.setPortName(portName);
 
-            if (wsdlURI != null) {
+            String noParsing = properties.getProperty(SKIP_WSDL_PARSING);
 
+            if (wsdlURI != null) {
                 wsdlEndpoint.setWsdlURI(wsdlURI.trim());
-                try {
-                    OMNode wsdlOM = SynapseConfigUtils.getOMElementFromURL(new 
URL(wsdlURI)
-                            .toString(), 
properties.get(SynapseConstants.SYNAPSE_HOME) != null ?
-                            
properties.get(SynapseConstants.SYNAPSE_HOME).toString() : "");
-                    if (wsdlOM != null && wsdlOM instanceof OMElement) {
-                        OMElement omElement = (OMElement) wsdlOM;
-                        OMNamespace ns = omElement.getNamespace();
-                        if (ns != null) {
-                            String nsUri = 
omElement.getNamespace().getNamespaceURI();
-                            if 
(org.apache.axis2.namespace.Constants.NS_URI_WSDL11.equals(nsUri)) {
-
-                                endpoint = new WSDL11EndpointBuilder().
-                                        createEndpointDefinitionFromWSDL(
-                                                wsdlURI.trim(), omElement, 
serviceName, portName);
-
-                            } else if 
(WSDL2Constants.WSDL_NAMESPACE.equals(nsUri)) {
-                                //endpoint = new WSDL20EndpointBuilder().
-                                // createEndpointDefinitionFromWSDL(wsdlURI, 
serviceName, portName);
+                if (noParsing == null || 
!JavaUtils.isTrueExplicitly(noParsing)) {
+                    try {
+                        OMNode wsdlOM = 
SynapseConfigUtils.getOMElementFromURL(new URL(wsdlURI)
+                                .toString(), 
properties.get(SynapseConstants.SYNAPSE_HOME) != null ?
+                                
properties.get(SynapseConstants.SYNAPSE_HOME).toString() : "");
+                        if (wsdlOM != null && wsdlOM instanceof OMElement) {
+                            OMElement omElement = (OMElement) wsdlOM;
+                            OMNamespace ns = omElement.getNamespace();
+                            if (ns != null) {
+                                String nsUri = 
omElement.getNamespace().getNamespaceURI();
+                                if 
(org.apache.axis2.namespace.Constants.NS_URI_WSDL11.equals(nsUri)) {
+
+                                    endpoint = new WSDL11EndpointBuilder().
+                                            createEndpointDefinitionFromWSDL(
+                                                    wsdlURI.trim(), omElement, 
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");
+                                    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);
                     }
-                } catch (Exception e) {
-                    handleException("Couldn't create endpoint from the given 
WSDL URI : "
-                            + e.getMessage(), e);
+                } else {
+                    endpoint = new EndpointDefinition();
                 }
             }
 
@@ -144,17 +152,20 @@ public class WSDLEndpointFactory extends
             if (endpoint == null && definitionElement != null) {
                 wsdlEndpoint.setWsdlDoc(definitionElement);
 
-                String resolveRoot = 
properties.get(SynapseConstants.RESOLVE_ROOT).toString();
-//                String resolveRoot = SynapseConfigUtils.getResolveRoot();
-                String baseUri = "file:./";
-                if (resolveRoot != null) {
-                    baseUri = resolveRoot.trim();
-                }
-                if (!baseUri.endsWith(File.separator)) {
-                    baseUri = baseUri + File.separator;
+                if (noParsing == null || 
!JavaUtils.isTrueExplicitly(noParsing)) {
+                    String resolveRoot = 
properties.get(SynapseConstants.RESOLVE_ROOT).toString();
+                    String baseUri = "file:./";
+                    if (resolveRoot != null) {
+                        baseUri = resolveRoot.trim();
+                    }
+                    if (!baseUri.endsWith(File.separator)) {
+                        baseUri = baseUri + File.separator;
+                    }
+                    endpoint = new 
WSDL11EndpointBuilder().createEndpointDefinitionFromWSDL(
+                            baseUri, definitionElement, serviceName, portName);
+                } else {
+                    endpoint = new EndpointDefinition();
                 }
-                endpoint = new 
WSDL11EndpointBuilder().createEndpointDefinitionFromWSDL(
-                        baseUri, definitionElement, serviceName, portName);
             }
 
             // check if a wsdl 2.0 document is supplied inline
@@ -168,7 +179,7 @@ public class WSDLEndpointFactory extends
                 // for now, QOS information has to be provided explicitly.
                 extractCommonEndpointProperties(endpoint, wsdlElement);
                 extractSpecificEndpointProperties(endpoint, wsdlElement);
-                wsdlEndpoint.setDefinition(endpoint);                   
+                wsdlEndpoint.setDefinition(endpoint);
                 processAuditStatus(endpoint, wsdlEndpoint.getName(), 
wsdlElement);
             } else {
                 handleException("WSDL is not specified for WSDL endpoint.");


Reply via email to