Author: gnodet
Date: Wed Jan 24 08:55:33 2007
New Revision: 499477

URL: http://svn.apache.org/viewvc?view=rev&rev=499477
Log:
Allow WS-Addressing EPR resolution when the XML fragment contains comments / 
text nodes in addition to the element

Modified:
    
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java?view=diff&rev=499477&r1=499476&r2=499477
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
 Wed Jan 24 08:55:33 2007
@@ -347,29 +347,31 @@
      */
     public ServiceEndpoint resolveStandardEPR(DocumentFragment epr) {
         try {
-            if (epr.getChildNodes().getLength() == 1) {
-                Node child = epr.getFirstChild();
-                if (child instanceof Element) {
-                    Element elem = (Element) child;
-                    NodeList nl = 
elem.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing";, "Address");
-                    if (nl.getLength() == 1) {
-                        Element address = (Element) nl.item(0);
-                        String uri = DOMUtil.getElementText(address);
-                        if (uri != null) {
-                            uri = uri.trim();
-                        }
-                        if (uri.startsWith("endpoint:")) {
-                            uri = uri.substring("endpoint:".length());
-                            String[] parts = split(uri);
-                            return getInternalEndpoint(new QName(parts[0], 
parts[1]), parts[2]);
-                        }
-                        else if (uri.startsWith("service:")) {
-                            uri = uri.substring("service:".length());
-                            String[] parts = splitService(uri);
-                            return getEndpoint(new QName(parts[0], parts[1]), 
parts[1]);
-                        }
-                        // TODO should we support interface: and operation: 
here?
+            NodeList children = epr.getChildNodes();
+            for (int i = 0 ; i < children.getLength(); ++i) {
+                Node n = children.item(i);
+                if (n.getNodeType() != Node.ELEMENT_NODE) {
+                    continue;
+                }
+                Element elem = (Element) n;
+                NodeList nl = 
elem.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing";, "Address");
+                if (nl.getLength() == 1) {
+                    Element address = (Element) nl.item(0);
+                    String uri = DOMUtil.getElementText(address);
+                    if (uri != null) {
+                        uri = uri.trim();
                     }
+                    if (uri.startsWith("endpoint:")) {
+                        uri = uri.substring("endpoint:".length());
+                        String[] parts = split(uri);
+                        return getInternalEndpoint(new QName(parts[0], 
parts[1]), parts[2]);
+                    }
+                    else if (uri.startsWith("service:")) {
+                        uri = uri.substring("service:".length());
+                        String[] parts = splitService(uri);
+                        return getEndpoint(new QName(parts[0], parts[1]), 
parts[1]);
+                    }
+                    // TODO should we support interface: and operation: here?
                 }
             }
         } catch (Exception e) {


Reply via email to