cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r695552 - in /cxf/trunk/tools: validator/src/main/java/org/apache/cxf/tools/validator/internal/ validator/src/test/java/org/apache/cxf/tools/validator/ validator/src/test/resources/validator_wsdl/ wsdlto/test/src/test/java/org/apache/cxf/to...
Date Mon, 15 Sep 2008 17:13:27 GMT
Author: dkulp
Date: Mon Sep 15 10:13:26 2008
New Revision: 695552

URL: http://svn.apache.org/viewvc?rev=695552&view=rev
Log:
[CXF-1793] Consider soap headers when determining if an operation is "unique"

Added:
    cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl   (with props)
Modified:
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
    cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
    cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java?rev=695552&r1=695551&r2=695552&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
(original)
+++ cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
Mon Sep 15 10:13:26 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/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java?rev=695552&r1=695551&r2=695552&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
(original)
+++ cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
Mon Sep 15 10:13:26 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/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?rev=695552&r1=695551&r2=695552&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++ cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Mon Sep 15 10:13:26 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 {

Added: cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl?rev=695552&view=auto
==============================================================================
--- cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl (added)
+++ cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl Mon Sep 15 10:13:26
2008
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions
+targetNamespace="http://cxf.apache.org/test/cxf1793/"
+xmlns:m="http://cxf.apache.org/test/cxf1793/"
+xmlns:misc="http://cxf.apache.org/test/cxf1793/types"
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+        <wsdl:documentation/>
+            <wsdl:types>
+        <schema xmlns="http://www.w3.org/2001/XMLSchema" 
+                targetNamespace="http://cxf.apache.org/test/cxf1793/types">
+            <element name="AutHeader">
+                <complexType>
+                    <sequence>
+                        <element name="headerVal" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="opOne">
+                <complexType>
+                    <sequence>
+                        <element name="foo" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="opOneResponse">
+                <complexType>
+                    <sequence>
+                        <element name="return" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+
+            <element name="opTwo">
+                <complexType>
+                    <sequence>
+                        <element name="foo" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+            <element name="opTwoResponse">
+                <complexType>
+                    <sequence>
+                        <element name="return" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+        
+        <wsdl:message name="opOne">
+                <wsdl:part name="header" element="misc:AutHeader"/>
+                <wsdl:part name="request" element="misc:opOne"/>
+        </wsdl:message>
+        
+        <wsdl:message name="opOneResponse">
+                <wsdl:part name="response" element="misc:opOneResponse" />
+        </wsdl:message>
+
+        <wsdl:message name="opTwo">
+                <wsdl:part name="header" element="misc:AutHeader"/>
+                <wsdl:part name="request" element="misc:opTwo"/>
+        </wsdl:message>
+        
+        <wsdl:message name="opTwoResponse">
+                <wsdl:part name="response" element="misc:opTwoResponse"/>
+        </wsdl:message>
+
+        <wsdl:portType name="MiscPort">
+                <wsdl:operation name="opOne">
+                        <wsdl:input message="m:opOne" />
+                        <wsdl:output message="m:opOneResponse"/>
+                </wsdl:operation>       
+                <wsdl:operation name="opTwo">
+                        <wsdl:input message="m:opTwo"/>
+                        <wsdl:output message="m:opTwoResponse"/>
+                </wsdl:operation>
+        </wsdl:portType>
+        
+        <wsdl:binding name="MiscSoapBinding" type="m:MiscPort">
+                <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+                <wsdl:operation name="opOne">
+                        <soap:operation soapAction="opOne" style="document"/>
+                        <wsdl:input>
+                                <soap:header message="m:opOne" part="header" use="literal"/>
+                                <soap:body parts="request" use="literal"/>
+                        </wsdl:input>
+                        <wsdl:output>
+                                <soap:body use="literal"/>
+                        </wsdl:output>
+                </wsdl:operation>
+                <wsdl:operation name="opTwo">
+                        <soap:operation soapAction="opTwo" style="document"/>
+                        <wsdl:input>
+                                <soap:header message="m:opTwo" part="header2" use="literal"/>
+                                <soap:body parts="request" use="literal"/>
+                        </wsdl:input>
+                        <wsdl:output>
+                                <soap:body use="literal"/>
+                        </wsdl:output>
+                </wsdl:operation>
+        </wsdl:binding>
+        
+        
+        <wsdl:service name="MiscService">
+                <wsdl:port name="MiscSoapPort" binding="m:MiscSoapBinding">
+                        <soap:address location="http://localhost:8080/adnfond/services/MiscService"/>
+                </wsdl:port>
+        </wsdl:service>
+</wsdl:definitions>

Propchange: cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/validator/src/test/resources/validator_wsdl/cxf1793.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=695552&r1=695551&r2=695552&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Mon Sep 15 10:13:26 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