geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r538433 - in /geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf: CXFWebServiceContainer.java GeronimoQueryHandler.java ejb/EJBInterceptor.java
Date Wed, 16 May 2007 05:17:44 GMT
Author: gawor
Date: Tue May 15 22:17:43 2007
New Revision: 538433

URL: http://svn.apache.org/viewvc?view=rev&rev=538433
Log:
expose imported wsdl or schema files properly

Added:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java?view=diff&rev=538433&r1=538432&r2=538433
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
Tue May 15 22:17:43 2007
@@ -16,22 +16,12 @@
  */
 package org.apache.geronimo.cxf;
 
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLWriter;
-import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -39,13 +29,9 @@
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
-import org.apache.cxf.tools.util.SOAPBindingUtil;
 import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.saaj.SAAJUniverse;
-import org.xmlsoap.schemas.wsdl.http.AddressType;
 
 public abstract class CXFWebServiceContainer implements WebServiceContainer {
 
@@ -92,6 +78,16 @@
 
     public void invoke(Request request, Response response) throws Exception {
         if (request.getMethod() == Request.GET) {
+            processGET(request, response);
+        } else {
+            processPOST(request, response);
+        }
+    }
+    
+    protected void processGET(Request request, Response response) throws Exception {
+        if (request.getParameter("xsd") != null || request.getParameter("XSD") != null) {
+            getWsdl(request, response);
+        } else {
             EndpointInfo ei = this.destination.getEndpointInfo();
             response.setContentType("text/html");
             PrintWriter pw = new PrintWriter(response.getOutputStream());
@@ -99,97 +95,29 @@
             pw.write("Hi, this is '" + ei.getService().getName().getLocalPart() + "' web
service.");
             pw.write("</body></html>");
             pw.flush();
-        } else {
-            SAAJUniverse universe = new SAAJUniverse();
-            universe.set(SAAJUniverse.SUN);
-            try {
-                destination.invoke(request, response);
-            } finally {
-                universe.unset();
-            }
         }
     }
-
-    public void getWsdl(Request request, Response response) throws Exception {
-        WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
-
-        EndpointInfo ei = this.destination.getEndpointInfo();
-
-        Definition def = new ServiceWSDLBuilder(bus,ei.getService()).build();
-        
-        QName serviceName = ei.getService().getName();
-        String portName = ei.getName().getLocalPart();
-        
-        updateServices(serviceName, portName, def, request);
-        
-        wsdlWriter.writeWSDL(def, response.getOutputStream());
-    }
     
-    private void updateServices(QName serviceName, String portName, Definition def, Request
request)
-        throws Exception {
-        boolean updated = false;
-        Map services = def.getServices();
-        if (services != null) {
-            Iterator serviceIterator = services.entrySet().iterator();
-            while (serviceIterator.hasNext()) {
-                Map.Entry serviceEntry = (Map.Entry) serviceIterator.next();
-                QName currServiceName = (QName) serviceEntry.getKey();
-                if (currServiceName.equals(serviceName)) {
-                    Service service = (Service) serviceEntry.getValue();
-                    updatePorts(portName, service, request);
-                    updated = true;
-                } else {
-                    def.removeService(currServiceName);
-                }
-            }
-        }
-        if (!updated) {
-            LOG.warn("WSDL '" + serviceName.getLocalPart() + "' service not found.");
+    protected void processPOST(Request request, Response response) throws Exception {
+        SAAJUniverse universe = new SAAJUniverse();
+        universe.set(SAAJUniverse.SUN);
+        try {
+            destination.invoke(request, response);
+        } finally {
+            universe.unset();
         }
     }
-    
-    private void updatePorts(String portName, Service service, Request request) 
-        throws Exception {
-        boolean updated = false;
-        Map ports = service.getPorts();
-        if (ports != null) {
-            Iterator portIterator = ports.entrySet().iterator();
-            while (portIterator.hasNext()) {
-                Map.Entry portEntry = (Map.Entry) portIterator.next();
-                String currPortName = (String) portEntry.getKey();
-                if (currPortName.equals(portName)) {
-                    Port port = (Port) portEntry.getValue();
-                    updatePortLocation(request, port);
-                    updated = true;
-                } else {
-                    service.removePort(currPortName);
-                }
-            }
-        }
-        if (!updated) {
-            LOG.warn("WSDL '" + portName + "' port not found.");
-        }        
-    }
-    
-    private void updatePortLocation(Request request, Port port) throws URISyntaxException
{
-        List<?> exts = port.getExtensibilityElements();
-        if (exts != null && exts.size() > 0) {
-            URI requestURI = request.getURI();
-            URI serviceURI = new URI(requestURI.getScheme(), null, 
-                                     requestURI.getHost(), requestURI.getPort(), 
-                                     requestURI.getPath(), null, null);
-            ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
-            if (SOAPBindingUtil.isSOAPAddress(el)) {
-                SoapAddress add = SOAPBindingUtil.getSoapAddress(el);
-                add.setLocationURI(serviceURI.toString());
-            }
-            if (el instanceof AddressType) {
-                AddressType add = (AddressType) el;
-                add.setLocation(serviceURI.toString());
-            }
-        }
-    }
-
+   
+    public void getWsdl(Request request, Response response) throws Exception {
+        GeronimoQueryHandler queryHandler = new GeronimoQueryHandler(this.bus);
+        URI requestURI = request.getURI();
+        EndpointInfo ei = this.destination.getEndpointInfo();
+        OutputStream out = response.getOutputStream();
+        String baseUri = requestURI.toString();
+        response.setContentType("text/xml");
+        queryHandler.writeResponse(baseUri, null, ei, out);
+    }    
+        
     public void destroy() {
         if (this.endpoint != null) {
             this.endpoint.stop();

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java?view=auto&rev=538433
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java
(added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java
Tue May 15 22:17:43 2007
@@ -0,0 +1,125 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.cxf;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
+import org.apache.cxf.transport.http.WSDLQueryHandler;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+public class GeronimoQueryHandler extends WSDLQueryHandler {
+
+    private static final Log LOG = LogFactory.getLog(GeronimoQueryHandler.class);
+
+    public GeronimoQueryHandler(Bus bus) {
+        super(bus);
+    }
+
+    protected void updateDefinition(Definition def,
+                                    Map<String, Definition> done,
+                                    Map<String, SchemaReference> doneSchemas,
+                                    String base,
+                                    EndpointInfo ei) {
+        if (done.get("") == def) {
+            QName serviceName = ei.getService().getName();
+            String portName = ei.getName().getLocalPart();
+            updateServices(serviceName, portName, def, base);
+        }
+        super.updateDefinition(def, done, doneSchemas, base, ei);
+    }
+
+    private void updateServices(QName serviceName, 
+                                String portName, 
+                                Definition def, 
+                                String baseUri) {
+        boolean updated = false;
+        Map services = def.getServices();
+        if (services != null) {
+            Iterator serviceIterator = services.entrySet().iterator();
+            while (serviceIterator.hasNext()) {
+                Map.Entry serviceEntry = (Map.Entry) serviceIterator.next();
+                QName currServiceName = (QName) serviceEntry.getKey();
+                if (currServiceName.equals(serviceName)) {
+                    Service service = (Service) serviceEntry.getValue();
+                    updatePorts(portName, service, baseUri);
+                    updated = true;
+                } else {
+                    def.removeService(currServiceName);
+                }
+            }
+        }
+        if (!updated) {
+            LOG.warn("WSDL '" + serviceName.getLocalPart() + "' service not found.");
+        }
+    }
+
+    private void updatePorts(String portName, 
+                             Service service, 
+                             String baseUri) {
+        boolean updated = false;
+        Map ports = service.getPorts();
+        if (ports != null) {
+            Iterator portIterator = ports.entrySet().iterator();
+            while (portIterator.hasNext()) {
+                Map.Entry portEntry = (Map.Entry) portIterator.next();
+                String currPortName = (String) portEntry.getKey();
+                if (currPortName.equals(portName)) {
+                    Port port = (Port) portEntry.getValue();
+                    updatePortLocation(port, baseUri);
+                    updated = true;
+                } else {
+                    service.removePort(currPortName);
+                }
+            }
+        }
+        if (!updated) {
+            LOG.warn("WSDL '" + portName + "' port not found.");
+        }
+    }
+
+    private void updatePortLocation(Port port, 
+                                    String baseUri) {
+        List<?> exts = port.getExtensibilityElements();
+        if (exts != null && exts.size() > 0) {
+            ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
+            if (SOAPBindingUtil.isSOAPAddress(el)) {
+                SoapAddress add = SOAPBindingUtil.getSoapAddress(el);
+                add.setLocationURI(baseUri);
+            }
+            if (el instanceof AddressType) {
+                AddressType add = (AddressType) el;
+                add.setLocation(baseUri);
+            }
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoQueryHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java?view=diff&rev=538433&r1=538432&r2=538433
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
Tue May 15 22:17:43 2007
@@ -178,13 +178,7 @@
         if (soapMessage == null) {
             return;
         }
-        
-        //replace header element if necessary
-        if (message.hasHeaders(Element.class)) {
-            Element headerElements = soapMessage.getSOAPHeader();    
-            message.setHeaders(Element.class, headerElements);
-        }
-        
+                
         XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
         StaxUtils.readDocElements(soapMessage.getSOAPBody(), xmlReader, true);
         DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
@@ -194,4 +188,4 @@
         message.setContent(XMLStreamReader.class, xmlReader);
     }
         
-}
\ No newline at end of file
+}



Mime
View raw message