geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r525375 - /geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Date Wed, 04 Apr 2007 03:11:23 GMT
Author: dims
Date: Tue Apr  3 20:11:22 2007
New Revision: 525375

URL: http://svn.apache.org/viewvc?view=rev&rev=525375
Log:
port code for updating the service/port/soapaddress

Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?view=diff&rev=525375&r1=525374&r2=525375
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Tue Apr  3 20:11:22 2007
@@ -58,6 +58,11 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.wsdl.Definition;
+import javax.wsdl.Service;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLWriter;
 import javax.xml.namespace.QName;
@@ -66,9 +71,11 @@
 import java.io.PrintWriter;
 import java.net.URI;
 import java.net.URL;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 
 /**
@@ -456,6 +463,14 @@
             if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals(""))
{ //wsdl file has been provided
                 Definition wsdlDefinition = new AxisServiceGenerator().getWSDLDefition(portInfo,
configurationBaseUrl, classLoader);
                 if(wsdlDefinition != null){
+                    String portName = portInfo.getPortName();
+                    QName qName = portInfo.getWsdlService();
+                    if(qName == null || portName == null) {
+                        log.info("Unable to call updateServices ["+ qName + "][" + portName
+"]");                        
+                    } else {
+                        log.info("calling updateServices ["+ qName + "][" + portName +"]");
                       
+                        updateServices(qName, portName, wsdlDefinition, request);
+                    }
                     WSDLFactory factory = WSDLFactory.newInstance();
                     WSDLWriter writer = factory.newWSDLWriter();                    
                     writer.writeWSDL(wsdlDefinition, response.getOutputStream());
@@ -556,4 +571,69 @@
                 soapAction,
                 request.getURI().getPath());
     }
+
+    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.");
+        }
+    }
+
+    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(el instanceof SOAP12Address){
+                SOAP12Address add = (SOAP12Address)el;
+                add.setLocationURI(serviceURI.toString());
+            } else if (el instanceof SOAPAddress) {
+                SOAPAddress add = (SOAPAddress)el;
+                add.setLocationURI(serviceURI.toString());
+            }
+        }
+    }
+
 }



Mime
View raw message