You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2007/05/21 18:11:48 UTC

svn commit: r540186 - in /incubator/ode/trunk: ./ axis2/src/main/java/org/apache/ode/axis2/ axis2/src/main/java/org/apache/ode/axis2/hooks/ bpel-api/src/main/java/org/apache/ode/bpel/iapi/ bpel-store/src/main/java/org/apache/ode/store/

Author: boisvert
Date: Mon May 21 09:11:47 2007
New Revision: 540186

URL: http://svn.apache.org/viewvc?view=rev&rev=540186
Log:
Fix ODE-130: Deploying document style wsdl to Axis2 results in empty wsdl types element

Modified:
    incubator/ode/trunk/Rakefile
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
    incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/ProcessConf.java
    incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java

Modified: incubator/ode/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/Rakefile?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/Rakefile (original)
+++ incubator/ode/trunk/Rakefile Mon May 21 09:11:47 2007
@@ -94,7 +94,7 @@
 WS_COMMONS          = struct(
   :axiom            =>AXIOM,
   :neethi           =>"org.apache.ws.commons.neethi:neethi:jar:2.0",
-  :xml_schema       =>"org.apache.ws.commons.schema:XmlSchema:jar:1.2"
+  :xml_schema       =>"org.apache.ws.commons.schema:XmlSchema:jar:1.3.1"
 )
 XBEAN               = group("xbean-classloader", "xbean-kernel", "xbean-server", "xbean-spring",
                         :under=>"org.apache.xbean", :version=>"2.8")
@@ -133,9 +133,10 @@
     compile.with projects("bpel-api", "bpel-connector", "bpel-dao", "bpel-epr", "bpel-runtime",
       "bpel-scheduler-quartz", "bpel-schemas", "bpel-store", "utils"),
       AXIOM, AXIS2, COMMONS.logging, COMMONS.collections, DERBY, GERONIMO.kernel, GERONIMO.transaction,
-      JAVAX.activation, JAVAX.servlet, JAVAX.stream, JAVAX.transaction, JENCKS, WSDL4J, XMLBEANS
+      JAVAX.activation, JAVAX.servlet, JAVAX.stream, JAVAX.transaction, JENCKS, WSDL4J, WS_COMMONS.xml_schema,
+      XMLBEANS
 
-    test.with project("tools"), XERCES, WOODSTOX, AXIOM, WS_COMMONS.xml_schema, JAVAX.javamail
+    test.with project("tools"), XERCES, WOODSTOX, AXIOM, JAVAX.javamail
     test.exclude '*'
 
     package :jar

Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java Mon May 21 09:11:47 2007
@@ -30,6 +30,7 @@
 import org.apache.ode.bpel.iapi.Endpoint;
 import org.apache.ode.bpel.iapi.EndpointReference;
 import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.bpel.iapi.ProcessConf;
 import org.apache.ode.bpel.iapi.ProcessStore;
 
 /**
@@ -50,11 +51,12 @@
 
     public EndpointReference activateMyRoleEndpoint(QName processId, Endpoint myRoleEndpoint) {
         try {
-        	Definition wsdl = _store.getProcessConfiguration(processId).getDefinitionForService(myRoleEndpoint.serviceName);
+            ProcessConf pconf = _store.getProcessConfiguration(processId); 
+        	Definition wsdl = pconf.getDefinitionForService(myRoleEndpoint.serviceName);
         	if (wsdl == null)
         		throw new ContextException("Unable to access WSDL definition to activate MyRole endpoint for service " + myRoleEndpoint.serviceName
         				+ " and port " + myRoleEndpoint.portName);
-            ODEService svc = _server.createService(wsdl, myRoleEndpoint.serviceName, myRoleEndpoint.portName);
+            ODEService svc = _server.createService(pconf, myRoleEndpoint.serviceName, myRoleEndpoint.portName);
             return svc.getMyServiceRef();
         } catch (AxisFault axisFault) {
             throw new ContextException("Could not activate endpoint for service " + myRoleEndpoint.serviceName

Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Mon May 21 09:11:47 2007
@@ -19,6 +19,19 @@
 
 package org.apache.ode.axis2;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.StringTokenizer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
@@ -47,18 +60,6 @@
 import org.apache.ode.store.ProcessStoreImpl;
 import org.apache.ode.utils.fs.TempFileManager;
 
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.wsdl.Definition;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.StringTokenizer;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
 /**
  * Server class called by our Axis hooks to handle all ODE lifecycle management.
  * 
@@ -291,13 +292,10 @@
         }
     }
 
-    public ODEService createService(Definition def, QName serviceName, String portName) throws AxisFault {
-        if (_services.get(serviceName, portName) != null) {
-            AxisService service = ((ODEService) _services.get(serviceName, portName)).getAxisService();
-            _axisConfig.removeService(service.getName());
-        }
-        AxisService axisService = ODEAxisService.createService(_axisConfig, def, serviceName, portName);
-        ODEService odeService = new ODEService(axisService, def, serviceName, portName, _server, _txMgr);
+    public ODEService createService(ProcessConf pconf, QName serviceName, String portName) throws AxisFault {
+        destroyService(serviceName);
+        AxisService axisService = ODEAxisService.createService(_axisConfig, pconf, serviceName, portName);
+        ODEService odeService = new ODEService(axisService, pconf.getDefinitionForService(serviceName), serviceName, portName, _server, _txMgr);
         if (_odeConfig.isReplicateEmptyNS()) {
             __log.debug("Setting service with empty namespace replication");
             odeService.setReplicateEmptyNS(true);
@@ -340,12 +338,14 @@
 
     public void destroyService(QName serviceName) {
         __log.debug("Destroying service " + serviceName);
+        ODEService service = (ODEService) _services.remove(serviceName);
+        if (service != null) {
         try {
-            _axisConfig.removeService(serviceName.getLocalPart());
+                _axisConfig.removeService(service.getAxisService().getName());
         } catch (AxisFault axisFault) {
             __log.error("Couldn't destroy service " + serviceName);
         }
-        _services.remove(serviceName);
+        }
     }
 
     public ODEService getService(QName serviceName, String portName) {

Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java Mon May 21 09:11:47 2007
@@ -19,13 +19,11 @@
 
 package org.apache.ode.axis2.hooks;
 
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.ode.axis2.OdeFault;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
@@ -34,24 +32,50 @@
 import javax.wsdl.Service;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.xml.namespace.QName;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.OdeFault;
+import org.apache.ode.axis2.util.Axis2UriResolver;
+import org.apache.ode.axis2.util.Axis2WSDLLocator;
+import org.apache.ode.bpel.iapi.ProcessConf;
 
 /**
- * Implementation of Axis Service used by ODE iapi to enlist itself
- * its service. Allows us to build the service using a WSDL definition
- * using our own receiver.
+ * Implementation of Axis Service used by ODE iapi to enlist itself its service. Allows us to build the service using a
+ * WSDL definition using our own receiver.
  */
 public class ODEAxisService extends AxisService {
 
-  public static AxisService createService(AxisConfiguration axisConfig, Definition wsdlDefinition,
-                                          QName wsdlServiceName, String portName) throws AxisFault {
+    private static final Log LOG = LogFactory.getLog(ODEAxisService.class);
+
+    public static AxisService createService(AxisConfiguration axisConfig, ProcessConf pconf, QName wsdlServiceName,
+            String portName) throws AxisFault {
+        Definition wsdlDefinition = pconf.getDefinitionForService(wsdlServiceName);
     String serviceName = extractServiceName(wsdlDefinition, wsdlServiceName, portName);
 
-    WSDL11ToAxisServiceBuilder serviceBuilder =
-            new WSDL11ToAxisServiceBuilder(wsdlDefinition, wsdlServiceName, portName);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Create AxisService:"
+                      +" service="+wsdlServiceName
+                      +" port="+portName
+                      +" WSDL="+wsdlDefinition.getDocumentBaseURI()
+                      +" BPEL="+pconf.getBpelDocument());
+        }
+        
+        try {
+            URI baseUri = pconf.getBaseURL().toURI().resolve(wsdlDefinition.getDocumentBaseURI());
+            InputStream is = baseUri.toURL().openStream();
+            WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(is, wsdlServiceName, portName);
+            serviceBuilder.setBaseUri(baseUri.toString());
+            serviceBuilder.setCustomResolver(new Axis2UriResolver());
+            serviceBuilder.setCustomWSLD4JResolver(new Axis2WSDLLocator(baseUri));
     serviceBuilder.setServerSide(true);
+
     AxisService axisService = serviceBuilder.populateService();
     axisService.setName(serviceName);
     axisService.setWsdlFound(true);
@@ -70,12 +94,14 @@
         }
     }
     return axisService;
+        } catch (Exception e) {
+            throw new AxisFault(e);
+        }
   }
 
   public static AxisService createService(AxisConfiguration axisConfig, QName serviceQName, String port,
                              String axisName, Definition wsdlDef, MessageReceiver receiver) throws AxisFault {
-    WSDL11ToAxisServiceBuilder serviceBuilder =
-            new WSDL11ToAxisServiceBuilder(wsdlDef, serviceQName, port);
+        WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(wsdlDef, serviceQName, port);
     AxisService axisService = serviceBuilder.populateService();
     axisService.setName(axisName);
     axisService.setWsdlFound(true);
@@ -90,35 +116,34 @@
     return axisService;
   }
 
-
-  private static String extractServiceName(Definition wsdlDefinition, QName wsdlServiceName, String portName) throws AxisFault {
+    private static String extractServiceName(Definition wsdlDefinition, QName wsdlServiceName, String portName)
+            throws AxisFault {
     String url = null;
     Service service = wsdlDefinition.getService(wsdlServiceName);
     if (service == null) {
-      throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition " + wsdlDefinition.getDocumentBaseURI());
+            throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition "
+                    + wsdlDefinition.getDocumentBaseURI());
     }
     Port port = service.getPort(portName);
     for (Object oext : port.getExtensibilityElements()) {
       if (oext instanceof SOAPAddress)
-        url = ((SOAPAddress)oext).getLocationURI();
+                url = ((SOAPAddress) oext).getLocationURI();
     }
     if (url == null) {
-      throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName +
-              " (necessary to establish the process target address)!");
+            throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName
+                    + " (necessary to establish the process target address)!");
     }
     String serviceName = parseURLForService(url);
     if (serviceName == null) {
-      throw new OdeFault("The soap:address used for service WSDL definition " + wsdlServiceName +
-              " and port " + portName + " should be of the form http://hostname:port/ode/processes/myProcessEndpointName");
+            throw new OdeFault("The soap:address used for service WSDL definition " + wsdlServiceName + " and port "
+                    + portName + " should be of the form http://hostname:port/ode/processes/myProcessEndpointName");
     }
     return serviceName;
   }
 
   /**
-   * Obtain the service name from the request URL. The request URL is
-   * expected to use the path "/processes/" under which all processes
-   * and their services are listed. Returns null if the path does not
-   * contain this part.
+     * Obtain the service name from the request URL. The request URL is expected to use the path "/processes/" under
+     * which all processes and their services are listed. Returns null if the path does not contain this part.
    */
   protected static String parseURLForService(String path) {
       int index = path.indexOf("/processes/");
@@ -139,10 +164,10 @@
       return null;
   }
 
-  private static void declarePartsElements(Definition wsdlDefinition, QName wsdlServiceName,
-                                           String axisServiceName, String portName) {
-    List wsldOps = wsdlDefinition.getService(wsdlServiceName).getPort(portName)
-            .getBinding().getPortType().getOperations();
+    private static void declarePartsElements(Definition wsdlDefinition, QName wsdlServiceName, String axisServiceName,
+            String portName) {
+        List wsldOps = wsdlDefinition.getService(wsdlServiceName).getPort(portName).getBinding().getPortType()
+                .getOperations();
     for (Object wsldOp : wsldOps) {
       Operation wsdlOp = (Operation) wsldOp;
       Collection parts = wsdlOp.getInput().getMessage().getParts().values();
@@ -151,9 +176,11 @@
         Part part = (Part) parts.iterator().next();
         // Parts are types, it's rpc/enc, no mapping needs to be declared
         if (part.getElementName() != null)
-          ODEAxisDispatcher.addElmtToOpMapping(axisServiceName, wsdlOp.getName(), part.getElementName().getLocalPart());
+                    ODEAxisDispatcher.addElmtToOpMapping(axisServiceName, wsdlOp.getName(), part.getElementName()
+                            .getLocalPart());
       }
     }
   }
 
+    
 }

Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/ProcessConf.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/ProcessConf.java?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/ProcessConf.java (original)
+++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/ProcessConf.java Mon May 21 09:11:47 2007
@@ -18,17 +18,19 @@
  */
 package org.apache.ode.bpel.iapi;
 
-import org.apache.ode.bpel.evt.BpelEvent.TYPE;
-import org.w3c.dom.Node;
-
-import javax.wsdl.Definition;
-import javax.xml.namespace.QName;
 import java.io.File;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.w3c.dom.Node;
+
 /**
  * Deployed process configuration. IMPORTANT: Implementations of this class <em>MUST BE IMMUTABLE</em>,
  * otherwise the engine will get confused.  
@@ -74,6 +76,11 @@
     String getBpelDocument();
    
     /**
+     * Get the base URL for resolving resources.  
+     */
+    URL getBaseURL();
+    
+    /**
      * Get the date of deployment.
      * @return
      */
@@ -139,6 +146,6 @@
      */
     Map<String, Endpoint> getInvokeEndpoints();
 
-    boolean isEventEnabled(List<String> scopeNames, TYPE type);
+    boolean isEventEnabled(List<String> scopeNames, BpelEvent.TYPE type);
     
 }

Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java?view=diff&rev=540186&r1=540185&r2=540186
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java Mon May 21 09:11:47 2007
@@ -23,6 +23,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -191,6 +193,14 @@
         }
     }
     
+    public URL getBaseURL() {
+        try {
+           return _du.getDeployDir().toURL();
+        } catch (MalformedURLException except) {
+            throw new RuntimeException(except);
+        }
+    }
+
     public ProcessState getState() {
         return _state;
     }
@@ -330,4 +340,5 @@
         if (relative.startsWith(File.separator)) relative = relative.substring(1);
         return relative;
     }
+
 }