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 am...@apache.org on 2007/11/29 16:36:10 UTC

svn commit: r599490 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java

Author: amilas
Date: Thu Nov 29 07:36:09 2007
New Revision: 599490

URL: http://svn.apache.org/viewvc?rev=599490&view=rev
Log:
used the existing protocol when setting the new epr address

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=599490&r1=599489&r2=599490&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Thu Nov 29 07:36:09 2007
@@ -1114,27 +1114,72 @@
                 for (int i = 0; i < list.size(); i++) {
                     Object extensibilityEle = list.get(i);
                     if (extensibilityEle instanceof SOAPAddress) {
+                        SOAPAddress soapAddress = (SOAPAddress) extensibilityEle;
+                        String exsistingAddress = soapAddress.getLocationURI();
                         if (requestIP == null) {
-                            ((SOAPAddress) extensibilityEle).setLocationURI(getEPRs()[0]);
+                            ((SOAPAddress) extensibilityEle).setLocationURI(
+                                    getLocationURI(getEPRs(), exsistingAddress));
                         } else {
-                            ((SOAPAddress) extensibilityEle).setLocationURI(calculateEPRs(requestIP)[0]);
+                            ((SOAPAddress) extensibilityEle).setLocationURI(
+                                    getLocationURI(calculateEPRs(requestIP), exsistingAddress));
                         }
                     } else if (extensibilityEle instanceof SOAP12Address){
+                        SOAP12Address soapAddress = (SOAP12Address) extensibilityEle;
+                        String exsistingAddress = soapAddress.getLocationURI();
                         if (requestIP == null) {
-                            ((SOAP12Address) extensibilityEle).setLocationURI(getEPRs()[0]);
+                            ((SOAP12Address) extensibilityEle).setLocationURI(
+                                    getLocationURI(getEPRs(), exsistingAddress));
                         } else {
-                            ((SOAP12Address) extensibilityEle).setLocationURI(calculateEPRs(requestIP)[0]);
+                            ((SOAP12Address) extensibilityEle).setLocationURI(
+                                    getLocationURI(calculateEPRs(requestIP), exsistingAddress));
                         }
                     } else if (extensibilityEle instanceof HTTPAddress){
+                        HTTPAddress httpAddress = (HTTPAddress) extensibilityEle;
+                        String exsistingAddress = httpAddress.getLocationURI();
                         if (requestIP == null) {
-                            ((HTTPAddress) extensibilityEle).setLocationURI(getEPRs()[0]);
+                            ((HTTPAddress) extensibilityEle).setLocationURI(
+                                    getLocationURI(getEPRs(), exsistingAddress));
                         } else {
-                            ((HTTPAddress) extensibilityEle).setLocationURI(calculateEPRs(requestIP)[0]);
+                            ((HTTPAddress) extensibilityEle).setLocationURI(
+                                    getLocationURI(calculateEPRs(requestIP), exsistingAddress));
                         }
                     }
                     //TODO : change the Endpoint refrence addess as well.
                 }
             }
+        }
+    }
+
+    /**
+     * this method returns the new IP address corresponding to the
+     * already existing ip
+     * @param eprs
+     * @param epr
+     * @return corresponding Ip address
+     */
+    private String getLocationURI(String[] eprs, String epr) throws AxisFault {
+        String returnIP = null;
+        if (epr != null) {
+            if (epr.indexOf(":") > -1) {
+                String existingProtocol = epr.substring(0, epr.indexOf(":")).trim();
+                String eprProtocol;
+                for (int i = 0; i < eprs.length; i++) {
+                    eprProtocol = eprs[i].substring(0, eprs[i].indexOf(":")).trim();
+                    if (eprProtocol.equals(existingProtocol)) {
+                        returnIP = eprs[i];
+                        break;
+                    }
+                }
+                if (returnIP != null) {
+                    return returnIP;
+                } else {
+                    throw new AxisFault("Server does not have an epr for the wsdl epr==>" + epr);
+                }
+            } else {
+                throw new AxisFault("invalid epr is given epr ==> " + epr);
+            }
+        } else {
+            throw new AxisFault("No epr is given in the wsdl port");
         }
     }
 



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