You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2003/03/17 17:28:45 UTC
cvs commit: xml-axis/java/src/org/apache/axis/message SOAPBody.java SOAPHeader.java
dims 2003/03/17 08:28:43
Modified: java/src/org/apache/axis/i18n resource.properties
java/src/org/apache/axis/message SOAPBody.java
SOAPHeader.java
Log:
Fix for Bug 18050 - SOAPBody and SOAPHeader should enforce child element types
Revision Changes Path
1.52 +4 -1 xml-axis/java/src/org/apache/axis/i18n/resource.properties
Index: resource.properties
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- resource.properties 9 Mar 2003 23:32:32 -0000 1.51
+++ resource.properties 17 Mar 2003 16:28:42 -0000 1.52
@@ -1135,4 +1135,7 @@
couldNotReadFromCharStream=Could not read from character stream
errorGetDocFromSOAPEnvelope=Could not get document from SOAPEnvelope
badEjbHomeType=The home object retrieved from jndi does not have the same type as the one specified in the config file
-badEncodingStyle=Unknown encoding style
\ No newline at end of file
+badEncodingStyle=Unknown encoding style
+
+badSOAPHeader00=a SOAPHeader may only have SOAPHeaderElement as its immediate children
+badSOAPBodyElement00=a SOAPBody may only have SOAPBodyElement as its immediate children
\ No newline at end of file
1.41 +22 -1 xml-axis/java/src/org/apache/axis/message/SOAPBody.java
Index: SOAPBody.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- SOAPBody.java 2 Mar 2003 06:36:19 -0000 1.40
+++ SOAPBody.java 17 Mar 2003 16:28:42 -0000 1.41
@@ -90,7 +90,10 @@
private boolean disableFormatting = false;
SOAPBody(SOAPEnvelope env, SOAPConstants soapConsts) {
- soapConstants = soapConsts;
+ super(Constants.ELEM_BODY,
+ Constants.NS_PREFIX_SOAP_ENV,
+ soapConsts.getEnvelopeURI());
+ soapConstants = soapConsts;
try {
setParentElement(env);
} catch (SOAPException ex) {
@@ -289,5 +292,23 @@
while ((i = bodyElements.indexOf(child)) != -1) {
bodyElements.remove(i);
}
+ }
+
+
+ /**
+ * we have to override this to enforce that SOAPHeader immediate
+ * children are exclusively of type SOAPHeaderElement (otherwise
+ * we'll get mysterious ClassCastExceptions down the road...)
+ *
+ * @param element
+ * @return
+ * @throws SOAPException
+ */
+ public SOAPElement addChildElement(SOAPElement element)
+ throws SOAPException {
+ if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
+ throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
+ }
+ return super.addChildElement(element);
}
}
1.68 +21 -0 xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
Index: SOAPHeader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- SOAPHeader.java 2 Mar 2003 06:36:19 -0000 1.67
+++ SOAPHeader.java 17 Mar 2003 16:28:42 -0000 1.68
@@ -92,6 +92,9 @@
private SOAPConstants soapConstants;
SOAPHeader(SOAPEnvelope env, SOAPConstants soapConsts) {
+ super(Constants.ELEM_HEADER,
+ Constants.NS_PREFIX_SOAP_ENV,
+ soapConsts.getEnvelopeURI());
soapConstants = soapConsts;
try {
setParentElement(env);
@@ -371,5 +374,23 @@
while ((i = headers.indexOf(child)) != -1) {
headers.remove(i);
}
+ }
+
+ /**
+ * we have to override this to enforce that SOAPHeader immediate
+ * children are exclusively of type SOAPHeaderElement (otherwise
+ * we'll get mysterious ClassCastExceptions down the road... )
+ *
+ * @param element child element
+ * @return soap element
+ * @throws SOAPException
+ */
+ public SOAPElement addChildElement(SOAPElement element)
+ throws SOAPException
+ {
+ if (!(element instanceof javax.xml.soap.SOAPHeaderElement)) {
+ throw new SOAPException(Messages.getMessage("badSOAPHeader00"));
+ }
+ return super.addChildElement(element);
}
}