You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2006/09/15 10:44:10 UTC

svn commit: r446548 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java

Author: deepal
Date: Fri Sep 15 01:44:09 2006
New Revision: 446548

URL: http://svn.apache.org/viewvc?view=rev&rev=446548
Log:
fixing AXIS2-957

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java?view=diff&rev=446548&r1=446547&r2=446548
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ListingAgent.java Fri Sep 15 01:44:09 2006
@@ -35,6 +35,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
+
 public class ListingAgent extends AbstractAgent {
 
     private static final String LIST_MULTIPLE_SERVICE_JSP_NAME =
@@ -112,6 +113,29 @@
         processListServices(httpServletRequest, httpServletResponse);
     }
 
+    private String extractHostAndPort(String filePart, boolean isHttp) {
+        int ipindex = filePart.indexOf("//");
+        String ip = null;
+        if (ipindex >= 0) {
+            ip = filePart.substring(ipindex + 2, filePart.length());
+            int seperatorIndex = ip.indexOf(":");
+            int slashIndex = ip.indexOf("/");
+            String port;
+            if (seperatorIndex >= 0) {
+                ip = ip.substring(0, seperatorIndex);
+                port = ip.substring(seperatorIndex + 1, slashIndex);
+            } else {
+                ip = ip.substring(0, slashIndex);
+                port = "80";
+            }
+            if (isHttp) {
+                configContext.setProperty(RUNNING_PORT, port);
+            }
+        }
+        return ip;
+    }
+
+
     public void processListService(HttpServletRequest req,
                                    HttpServletResponse res)
             throws IOException, ServletException {
@@ -127,51 +151,24 @@
         if ((services != null) && !services.isEmpty()) {
             Object serviceObj = services.get(serviceName);
             if (serviceObj != null) {
-                if (wsdl2 >=0) {
+                boolean isHttp = "http".equals(req.getScheme());
+                if (wsdl2 >= 0) {
                     OutputStream out = res.getOutputStream();
                     res.setContentType("text/xml");
-                    int ipindex = filePart.indexOf("//");
-                    String ip = null;
-                    if (ipindex >= 0) {
-                        ip = filePart.substring(ipindex + 2, filePart.length());
-                        int seperatorIndex = ip.indexOf(":");
-                        int slashIndex = ip.indexOf("/");
-                        String port = ip.substring(seperatorIndex + 1,
-                                slashIndex);
-                        if ("http".equals(req.getScheme())) {
-                            configContext.setProperty(RUNNING_PORT, port);
-                        }
-                        if (seperatorIndex > 0) {
-                            ip = ip.substring(0, seperatorIndex);
-                        }
-                    }
+                    String ip = extractHostAndPort(filePart, isHttp);
                     ((AxisService) serviceObj).printWSDL2(out, ip, configContext.getServiceContextPath());
                     out.flush();
                     out.close();
                     return;
-                } else   if (wsdl >=0) {
+                } else if (wsdl >= 0) {
                     OutputStream out = res.getOutputStream();
                     res.setContentType("text/xml");
-                    int ipindex = filePart.indexOf("//");
-                    String ip = null;
-                    if (ipindex >= 0) {
-                        ip = filePart.substring(ipindex + 2, filePart.length());
-                        int seperatorIndex = ip.indexOf(":");
-                        int slashIndex = ip.indexOf("/");
-                        String port = ip.substring(seperatorIndex + 1,
-                                slashIndex);
-                        if ("http".equals(req.getScheme())) {
-                            configContext.setProperty(RUNNING_PORT, port);
-                        }
-                        if (seperatorIndex > 0) {
-                            ip = ip.substring(0, seperatorIndex);
-                        }
-                    }
+                    String ip = extractHostAndPort(filePart, isHttp);
                     ((AxisService) serviceObj).printWSDL(out, ip, configContext.getServicePath());
                     out.flush();
                     out.close();
                     return;
-                } else if (xsd >=0) {
+                } else if (xsd >= 0) {
                     OutputStream out = res.getOutputStream();
                     res.setContentType("text/xml");
                     AxisService axisService = (AxisService) serviceObj;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org