This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcxf_6488.patch
104 lines (99 loc) · 5.85 KB
/
cxf_6488.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Index: tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
===================================================================
diff -u -N -r8e378c3d50f53aaacb8550bf96489bc820ff2458 -r35ae7e4514b22fc42a7d090b4eb83f5c9086b195
--- tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java (.../WSIBPValidator.java) (revision 8e378c3d50f53aaacb8550bf96489bc820ff2458)
+++ tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java (.../WSIBPValidator.java) (revision 35ae7e4514b22fc42a7d090b4eb83f5c9086b195)
@@ -22,8 +22,11 @@
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.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 @@
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 @@
}
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 @@
}
if (operation.getOutput() != null && operation.getOutput().getMessage() != null) {
Message outMess = operation.getOutput().getMessage();
+ Set<String> ignorableParts = getIgnorableParts(bop.getBindingOutput());
+
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 @@
}
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 @@
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());