Author: darran.lofthouse(a)jboss.com
Date: 2007-05-11 10:55:35 -0400 (Fri, 11 May 2007)
New Revision: 3052
Modified:
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageDispatcher.java
Log:
ClassCastException fixes.
Modified:
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
---
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-05-11
14:54:59 UTC (rev 3051)
+++
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-05-11
14:55:35 UTC (rev 3052)
@@ -67,6 +67,7 @@
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.core.soap.SOAPHeaderElementImpl;
import org.jboss.ws.core.soap.SOAPMessageImpl;
+import org.jboss.ws.core.soap.TextImpl;
import org.jboss.ws.core.soap.UnboundHeader;
import org.jboss.ws.core.soap.attachment.AttachmentPartImpl;
import org.jboss.ws.core.soap.attachment.CIDGenerator;
@@ -229,10 +230,10 @@
log.debug("Add unboundHeader element: " + soapName);
SOAPContentElement contentElement = new
SOAPHeaderElementImpl(soapName);
contentElement.setParamMetaData(unboundHeader.toParameterMetaData(opMetaData));
-
+
if (soapHeader == null)
soapHeader = soapEnvelope.addHeader();
-
+
soapHeader.addChildElement(contentElement);
contentElement.setObjectValue(value);
}
@@ -291,7 +292,18 @@
SOAPElement soapBodyElement = soapBody;
if (style == Style.RPC)
{
- soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ soapBodyElement = null;
+
+ Iterator it = soapBody.getChildElements();
+ while (soapBodyElement == null && it.hasNext())
+ {
+ Object current = it.next();
+ if (current instanceof SOAPElement)
+ {
+ soapBodyElement = (SOAPElement)current;
+ }
+ }
+
Name elName = soapBodyElement.getElementName();
QName elQName = new QName(elName.getURI(), elName.getLocalName(),
elName.getPrefix());
@@ -804,8 +816,14 @@
Iterator childElements = soapElement.getChildElements();
while (childElements.hasNext())
{
- SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
+ Object child = childElements.next();
+ if (child instanceof TextImpl)
+ {
+ continue;
+ }
+ SOAPElementImpl childElement = (SOAPElementImpl)child;
+
// If this message was manipulated by a handler the child may not be a content
element
if (!(childElement instanceof SOAPContentElement))
childElement = (SOAPContentElement)soapElement.replaceChild(new
SOAPContentElement(childElement), childElement);
Modified:
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageDispatcher.java
===================================================================
---
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageDispatcher.java 2007-05-11
14:54:59 UTC (rev 3051)
+++
branches/dlofthouse/JBWS-1648/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageDispatcher.java 2007-05-11
14:55:35 UTC (rev 3052)
@@ -68,7 +68,8 @@
if (wsaAction.equals(opAux.getSOAPAction()))
{
opMetaData = opAux;
- if(log.isDebugEnabled()) log.debug("Use wsa:Action dispatch: " +
wsaAction);
+ if (log.isDebugEnabled())
+ log.debug("Use wsa:Action dispatch: " + wsaAction);
break;
}
}
@@ -87,8 +88,19 @@
SOAPBody soapBody = soapMessage.getSOAPBody();
Iterator bodyChildren = soapBody.getChildElements();
- if (bodyChildren.hasNext() == false)
+ SOAPBodyElement soapBodyElement = null;
+
+ while (bodyChildren.hasNext() && soapBodyElement == null)
{
+ Object next = bodyChildren.next();
+ if (next instanceof SOAPBodyElement)
+ {
+ soapBodyElement = (SOAPBodyElement)next;
+ }
+ }
+
+ if (soapBodyElement == null)
+ {
if (epMetaData.getStyle() == Style.RPC)
throw new SOAPException("Empty SOAP body with no child element not
supported for RPC");
@@ -97,7 +109,8 @@
{
if (opAux.getParameters().size() == 0)
{
- if(log.isDebugEnabled()) log.debug ("Dispatching empty SOAP
body");
+ if (log.isDebugEnabled())
+ log.debug("Dispatching empty SOAP body");
opMetaData = opAux;
break;
}
@@ -105,7 +118,6 @@
}
else
{
- SOAPBodyElement soapBodyElement = (SOAPBodyElement)bodyChildren.next();
Name soapName = soapBodyElement.getElementName();
QName xmlElementName = new QName(soapName.getURI(),
soapName.getLocalName());
opMetaData = epMetaData.getOperation(xmlElementName);
@@ -119,14 +131,16 @@
{
if (opAux.isMessageEndpoint())
{
- if(log.isDebugEnabled()) log.debug("Use generic message style
dispatch");
+ if (log.isDebugEnabled())
+ log.debug("Use generic message style dispatch");
opMetaData = opAux;
break;
}
}
}
- if(log.isDebugEnabled()) log.debug("getDispatchDestination: " +
(opMetaData != null ? opMetaData.getQName() : null));
+ if (log.isDebugEnabled())
+ log.debug("getDispatchDestination: " + (opMetaData != null ?
opMetaData.getQName() : null));
return opMetaData;
}
}
\ No newline at end of file