cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: [CXF-6488] Binding style vs part type R2203 And R2204 problems in wsdl document
Date Mon, 17 Aug 2015 11:56:26 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7de1b04ff -> 35ae7e451


[CXF-6488] Binding style vs part type R2203 And R2204 problems in wsdl document


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/35ae7e45
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/35ae7e45
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/35ae7e45

Branch: refs/heads/3.0.x-fixes
Commit: 35ae7e4514b22fc42a7d090b4eb83f5c9086b195
Parents: 7de1b04
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Mon Aug 17 13:51:32 2015 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Mon Aug 17 13:55:52 2015 +0200

----------------------------------------------------------------------
 .../validator/internal/WSIBPValidator.java      | 41 +++++++++-
 .../cxf/tools/validator/WSDLValidationTest.java |  8 ++
 .../test/resources/validator_wsdl/cxf6488.wsdl  | 84 ++++++++++++++++++++
 3 files changed, 129 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/35ae7e45/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
----------------------------------------------------------------------
diff --git a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
index fc70e91..e042087 100644
--- a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
+++ b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
@@ -22,8 +22,11 @@ package org.apache.cxf.tools.validator.internal;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+
 import javax.jws.soap.SOAPBinding;
 import javax.wsdl.Binding;
 import javax.wsdl.BindingOperation;
@@ -33,6 +36,10 @@ import javax.wsdl.Message;
 import javax.wsdl.Operation;
 import javax.wsdl.Part;
 import javax.wsdl.PortType;
+import javax.wsdl.WSDLElement;
+import javax.wsdl.extensions.mime.MIMEContent;
+import javax.wsdl.extensions.mime.MIMEMultipartRelated;
+import javax.wsdl.extensions.mime.MIMEPart;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.binding.soap.SOAPBindingUtil;
@@ -318,11 +325,12 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
                 BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
                 if (operation.getInput() != null && operation.getInput().getMessage()
!= null) {
                     Message inMess = operation.getInput().getMessage();
+                    Set<String> ignorableParts = getIgnorableParts(bop.getBindingInput());
 
                     for (Iterator<?> ite3 = inMess.getParts().values().iterator();
ite3.hasNext();) {
                         Part p = (Part)ite3.next();
                         if (SOAPBinding.Style.RPC.name().equalsIgnoreCase(style) &&
p.getTypeName() == null
-                            && !isHeaderPart(bop, p)) {
+                            && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(),
ignorableParts)) {
                             addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST
refer, "
                                             + "in its soapbind:body element(s), only to "
                                             + "wsdl:part element(s) that have been defined
"
@@ -331,7 +339,7 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
                         }
 
                         if (SOAPBinding.Style.DOCUMENT.name().equalsIgnoreCase(style)
-                            && p.getElementName() == null) {
+                            && p.getElementName() == null && !isIgnorablePart(p.getName(),
ignorableParts)) {
                             addErrorMessage("A document-literal binding in a DESCRIPTION
MUST refer, "
                                             + "in each of its soapbind:body element(s),"
                                             + "only to wsdl:part element(s)"
@@ -343,10 +351,12 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
                 }
                 if (operation.getOutput() != null && operation.getOutput().getMessage()
!= null) {
                     Message outMess = operation.getOutput().getMessage();
+                    Set<String> ignorableParts = getIgnorableParts(bop.getBindingInput());
+
                     for (Iterator<?> ite3 = outMess.getParts().values().iterator();
ite3.hasNext();) {
                         Part p = (Part)ite3.next();
                         if (style.equalsIgnoreCase(SOAPBinding.Style.RPC.name()) &&
p.getTypeName() == null
-                            &&  !isHeaderPart(bop, p)) {
+                            && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(),
ignorableParts)) {
                             addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST
refer, "
                                             + "in its soapbind:body element(s), only to "
                                             + "wsdl:part element(s) that have been defined
"
@@ -355,7 +365,7 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
                         }
 
                         if (style.equalsIgnoreCase(SOAPBinding.Style.DOCUMENT.name())
-                            && p.getElementName() == null) {
+                            && p.getElementName() == null && !isIgnorablePart(p.getName(),
ignorableParts)) {
                             addErrorMessage("A document-literal binding in a DESCRIPTION
MUST refer, "
                                             + "in each of its soapbind:body element(s),"
                                             + "only to wsdl:part element(s)"
@@ -371,6 +381,29 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
         return true;
     }
 
+    private static boolean isIgnorablePart(String name, Set<String> ignorableParts)
{
+        return ignorableParts != null && ignorableParts.contains(name);
+    }
+
+    private static Set<String> getIgnorableParts(WSDLElement ext) {
+        Set<String> parts = null;
+        if (ext != null && ext.getExtensibilityElements() != null && ext.getExtensibilityElements().size()
> 0
+            && ext.getExtensibilityElements().get(0) instanceof MIMEMultipartRelated)
{
+            MIMEMultipartRelated mpr = (MIMEMultipartRelated)ext.getExtensibilityElements().get(0);
+            List<MIMEPart> mps = CastUtils.cast(mpr.getMIMEParts());
+            parts = new HashSet<String>(mps.size());
+            for (Iterator<MIMEPart> it = mps.iterator(); it.hasNext();) {
+                MIMEPart mp = it.next();
+                if (mp.getExtensibilityElements() != null && mp.getExtensibilityElements().size()
> 0
+                    && mp.getExtensibilityElements().get(0) instanceof MIMEContent)
{
+                    parts.add(((MIMEContent)mp.getExtensibilityElements().get(0)).getPart());
+                }
+            }
+        }
+
+        return parts;
+    }
+
     // TODO: Should also check SoapHeader/SoapHeaderFault
     public boolean checkR2205() {
         Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());

http://git-wip-us.apache.org/repos/asf/cxf/blob/35ae7e45/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
----------------------------------------------------------------------
diff --git a/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
b/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
index 9093221..2e34f3d 100644
--- a/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
+++ b/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
@@ -175,6 +175,14 @@ public class WSDLValidationTest extends ToolTestBase {
     }
 
     @Test
+    public void testWSIBPR2203ExcludeMIMEParts() throws Exception {
+        String[] args = new String[] {"-verbose",
+                                      getLocation("/validator_wsdl/cxf6488.wsdl")};
+        WSDLValidator.main(args);
+        assertTrue(getStdOut().indexOf("Passed Validation : Valid WSDL") > -1);
+    }
+
+    @Test
     public void testWSIBPR2209() throws Exception {
         String[] args = new String[] {"-verbose",
                                       getLocation("/validator_wsdl/hello_world_unbound_porttype_elements.wsdl")};

http://git-wip-us.apache.org/repos/asf/cxf/blob/35ae7e45/tools/validator/src/test/resources/validator_wsdl/cxf6488.wsdl
----------------------------------------------------------------------
diff --git a/tools/validator/src/test/resources/validator_wsdl/cxf6488.wsdl b/tools/validator/src/test/resources/validator_wsdl/cxf6488.wsdl
new file mode 100644
index 0000000..6fc81e6
--- /dev/null
+++ b/tools/validator/src/test/resources/validator_wsdl/cxf6488.wsdl
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8" ?> 
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<!-- 
+  http://www.ws-i.org/profiles/attachmentsprofile-1.0.html#Referencing_Attachments_from_the_SOAP_Envelope

+-->
+<wsdl:definitions xmlns:types="http://example.com/mimetypes"
+                  xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+                  targetNamespace="http://example.com/mimewsdl"
+                  xmlns:tns="http://example.com/mimewsdl">
+
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://example.com/mimetypes"
+                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+            <xsd:import namespace="http://ws-i.org/profiles/basic/1.1/xsd" />
+            <xsd:element name="ClaimDetail" type="types:ClaimDetailType"/>
+            <xsd:complexType name="ClaimDetailType">
+                <xsd:sequence>
+                    <xsd:element name="Name" type="xsd:string"/>
+                    <xsd:element name="ClaimForm" type="ref:swaRef"/>
+                </xsd:sequence>
+            </xsd:complexType>
+            <xsd:element name="ClaimRefNo" type="xsd:string"/>
+        </xsd:schema>
+    </wsdl:types>
+
+    <wsdl:message name="ClaimIn">
+        <wsdl:part name="body" element="types:ClaimDetail"/>
+        <wsdl:part name="ClaimPhoto" type="xsd:base64Binary"/>
+    </wsdl:message>
+
+    <wsdl:message name="ClaimOut">
+        <wsdl:part name="out" element="types:ClaimRefNo"/>
+    </wsdl:message>
+
+    <wsdl:portType name="ClaimPortType">
+        <wsdl:operation name="SendClaim">
+            <wsdl:input message="tns:ClaimIn"/>
+            <wsdl:output message="tns:ClaimOut"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="ClaimBinding" type="tns:ClaimPortType">
+        <soapbind:binding style="document" 
+                          transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="SendClaim">
+            <soapbind:operation soapAction="http://example.com/soapaction"/>
+            <wsdl:input>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soapbind:body parts="body" use="literal"/>
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="ClaimPhoto" type="image/jpeg"/>
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:input>
+            <wsdl:output>
+                <soapbind:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+</wsdl:definitions>


Mime
View raw message