cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r695555 - in /cxf/branches/2.1.x-fixes: ./ tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ tools/validator/src/test/java/org/apache/cxf/tools/validator/ tools/validator/src/test/resources/validator_wsdl/ tools/wsdlto/...
Date Mon, 15 Sep 2008 17:19:38 GMT
Author: dkulp
Date: Mon Sep 15 10:19:37 2008
New Revision: 695555

URL: http://svn.apache.org/viewvc?rev=695555&view=rev
Log:
Merged revisions 695552 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r695552 | dkulp | 2008-09-15 13:13:26 -0400 (Mon, 15 Sep 2008) | 2 lines
  
  [CXF-1793] Consider soap headers when determining if an operation is "unique"
........

Added:
    cxf/branches/2.1.x-fixes/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
      - copied unchanged from r695552, cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
    cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
    cxf/branches/2.1.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
    cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 15 10:19:37 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java?rev=695555&r1=695554&r2=695555&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
Mon Sep 15 10:19:37 2008
@@ -132,7 +132,7 @@
 
         for (InputSource is : xsdsInJar) {
             Message msg = new Message("CREATE_SCHEMA_LOADED_FROM_JAR", LOG, is.getSystemId());
-            LOG.log(Level.INFO, msg.toString());
+            LOG.log(Level.FINE, msg.toString());
             Document doc = docBuilder.parse(is.getByteStream());
             DOMSource stream = new DOMSource(doc, is.getSystemId());
             stream.setSystemId(is.getSystemId());
@@ -361,7 +361,7 @@
     public LSInput resolveResource(String type, String namespaceURI, String publicId, String
systemId,
             String baseURI) {
         Message msg = new Message("RESOLVE_SCHEMA", LOG, namespaceURI, systemId, baseURI);
-        LOG.log(Level.INFO, msg.toString());
+        LOG.log(Level.FINE, msg.toString());
         if (NSFILEMAP.containsKey(namespaceURI)) {
             return loadLSInput(namespaceURI);
         }
@@ -398,7 +398,7 @@
                     lsin.setSystemId(resURL);
                     lsin.setByteStream(urlCon.getInputStream());
                     msg = new Message("RESOLVE_FROM_REMOTE", LOG, url);
-                    LOG.log(Level.INFO, msg.toString());
+                    LOG.log(Level.FINE, msg.toString());
                     return lsin;
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -415,7 +415,7 @@
         URIResolver resolver;
         try {
             msg = new Message("RESOLVE_FROM_LOCAL", LOG, localFile);
-            LOG.log(Level.INFO, msg.toString());
+            LOG.log(Level.FINE, msg.toString());
 
             resolver = new URIResolver(localFile);
             if (resolver.isResolved()) {

Modified: cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java?rev=695555&r1=695554&r2=695555&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
Mon Sep 15 10:19:37 2008
@@ -19,17 +19,26 @@
 
 package org.apache.cxf.tools.validator.internal;
 
+import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
 import javax.wsdl.Message;
 import javax.wsdl.Operation;
 import javax.wsdl.Part;
-import javax.wsdl.PortType;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPHeader;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.helpers.CastUtils;
+
 public class UniqueBodyPartsValidator extends AbstractDefinitionValidator {
     private Map<QName, String> uniqueBodyPartsMap;
 
@@ -38,44 +47,65 @@
     }
 
     public boolean isValid() {
-        Iterator ite = def.getPortTypes().values().iterator();
-        while (ite.hasNext()) {
-            //
-            // Only check for unique body parts per portType.
-            // (Create a new Map for each portType.)
-            //
+        Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
+        for (Binding binding : bindings) {
             uniqueBodyPartsMap = new HashMap<QName, String>();
-            PortType portType = (PortType)ite.next();
-            Iterator ite2 = portType.getOperations().iterator();
-            while (ite2.hasNext()) {
-                Operation operation = (Operation)ite2.next();
+            List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
+            for (BindingOperation op : ops) {
+                Operation operation = op.getOperation();
                 if (operation.getInput() != null) {
                     Message inMessage = operation.getInput().getMessage();
-                    if (inMessage != null && !isUniqueBodyPart(operation.getName(),
inMessage)) {
+                    BindingInput bin = op.getBindingInput();
+                    Set<String> headers = new HashSet<String>();
+                    if (bin != null) {
+                        List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
+                        for (ExtensibilityElement ext : lst) {
+                            if (!(ext instanceof SOAPHeader)) {
+                                continue;
+                            }
+                            SOAPHeader header = (SOAPHeader)ext;
+                            if (!header.getMessage().equals(inMessage.getQName())) {
+                                continue;
+                            }
+                            headers.add(header.getPart());
+                        }
+                    }
+                    
+                    //find the headers as they don't contribute to the body
+                    
+                    if (inMessage != null && !isUniqueBodyPart(operation.getName(),

+                                                               inMessage,
+                                                               headers,
+                                                               binding.getQName())) {
                         return false;
                     }
                 }
             }
         }
         return true;
-
     }
 
-    private boolean isUniqueBodyPart(String operationName, Message msg) {
-        Map partsMap = msg.getParts();
-        Iterator ite = partsMap.values().iterator();
-        if (ite.hasNext()) {
-            Part part = (Part)ite.next();
+    private boolean isUniqueBodyPart(String operationName, Message msg,
+                                     Collection<String> headers, QName bindingName)
{
+        List<Part> partList = CastUtils.cast(msg.getOrderedParts(null));
+        for (Part part : partList) {
+            if (headers.contains(part.getName())) {
+                continue;
+            }
             if (part.getElementName() == null) {
                 return true;
             }
             String opName = getOperationNameWithSamePart(operationName, part);
             if (opName != null) {
                 addErrorMessage("Non unique body parts, operation " + "[ " + opName + " ]
"
-                                + "and  operation [ " + operationName + " ] have the same
body block "
+                                + "and  operation [ " + operationName + " ] in binding "
+                                + bindingName.toString()
+                                + " have the same body block: "
                                 + part.getElementName());
                 return false;
             }
+            //just need to check the first element
+            return true;
         }
         return true;
     }

Modified: cxf/branches/2.1.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?rev=695555&r1=695554&r2=695555&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Mon Sep 15 10:19:37 2008
@@ -117,6 +117,14 @@
         assertTrue("Is not valid wsdl: " + getStdOut(),
                    getStdOut().indexOf("Passed Validation") > -1);
     }
+    @Test
+    public void testSOAPHeadersInMultiOperations() throws Exception {
+        String[] args = new String[] {"-verbose",
+                                      getLocation("/validator_wsdl/cxf1793.wsdl")};
+        WSDLValidator.main(args);
+        assertTrue(getStdErr(), getStdOut().indexOf("Passed Validation : Valid WSDL") >
-1);
+    }
+
 
     @Test
     public void testWSIBP2210() throws Exception {

Modified: cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=695555&r1=695554&r2=695555&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Mon Sep 15 10:19:37 2008
@@ -1270,4 +1270,14 @@
         assertEquals(1, sei.getMethods().length);
         assertFalse(Void.TYPE.equals(sei.getMethods()[0].getReturnType()));
     }
+
+    @Test
+    public void testsafasdasf()  throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, 
+                "/tmp/cxf-1793/src/main/resources/com/edb/adnfond/transport/ws/misc/HeaderInRequestMsg.wsdl");
+        env.put(ToolConstants.CFG_EXTRA_SOAPHEADER, "TRUE");
+        env.put(ToolConstants.CFG_VALIDATE_WSDL, ToolConstants.CFG_VALIDATE_WSDL);
+        processor.setContext(env);
+        processor.execute();
+    }
 }



Mime
View raw message