Author: darran.lofthouse(a)jboss.com
Date: 2007-06-25 07:33:22 -0400 (Mon, 25 Jun 2007)
New Revision: 3711
Modified:
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/JBWS1610TestCase.java
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/TestHandler.java
Log:
Fix test case regressions JBWS-1610
Modified:
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
===================================================================
---
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2007-06-25
09:49:01 UTC (rev 3710)
+++
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2007-06-25
11:33:22 UTC (rev 3711)
@@ -26,6 +26,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Iterator;
import javax.management.MBeanException;
import javax.xml.namespace.QName;
@@ -49,7 +50,6 @@
import org.jboss.ws.core.jaxws.binding.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS;
import org.jboss.ws.core.soap.MessageContextAssociation;
-import org.jboss.ws.core.soap.SOAPBodyImpl;
import org.jboss.ws.core.soap.SOAPMessageImpl;
import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.extensions.xop.XOPContext;
@@ -238,9 +238,20 @@
{
String faultString;
SOAPBody soapBody = reqMessage.getSOAPBody();
- if (soapBody.getChildElements().hasNext())
+ Iterator bodyChildren = soapBody.getChildElements();
+ SOAPBodyElement soapBodyElement = null;
+
+ while (bodyChildren.hasNext() && soapBodyElement == null)
{
- SOAPBodyElement soapBodyElement =
(SOAPBodyElement)soapBody.getChildElements().next();
+ Object next = bodyChildren.next();
+ if (next instanceof SOAPBodyElement)
+ {
+ soapBodyElement = (SOAPBodyElement)next;
+ }
+ }
+
+ if (soapBodyElement != null)
+ {
Name soapName = soapBodyElement.getElementName();
faultString = "Endpoint " + epMetaData.getPortName() + " does
not contain operation meta data for: " + soapName;
}
Modified:
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
---
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2007-06-25
09:49:01 UTC (rev 3710)
+++
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2007-06-25
11:33:22 UTC (rev 3711)
@@ -632,7 +632,7 @@
Iterator it = getChildElements();
while (it.hasNext())
{
- SOAPElement el = (SOAPElement)it.next();
+ Node el = (Node)it.next();
el.detachNode();
}
}
Modified:
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/JBWS1610TestCase.java
===================================================================
---
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/JBWS1610TestCase.java 2007-06-25
09:49:01 UTC (rev 3710)
+++
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/JBWS1610TestCase.java 2007-06-25
11:33:22 UTC (rev 3711)
@@ -21,13 +21,22 @@
*/
package org.jboss.test.ws.jaxrpc.jbws1610;
+import java.io.ByteArrayInputStream;
+
import javax.naming.InitialContext;
import javax.xml.rpc.Service;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPMessage;
import junit.framework.Test;
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
+import org.jboss.ws.core.soap.NameImpl;
/**
* Test case for fixes being merged for support patch: -
@@ -70,4 +79,36 @@
assertEquals("String Modifed By Handler", "YYXXFirst
StringXXYY", response.getStringA());
assertEquals("String Modifed By Handler", "YYXXSecond
StringXXYY", response.getStringB());
}
+
+ public void testCallWithComments() throws Exception
+ {
+ String message =
+ "<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:typ='http://org.jboss.test.ws/jbws1610/types'>" +
+ " <!-- Comment Before Header -->" +
+ " <soapenv:Header/>" +
+ " <!-- Comment After Header -->" +
+ " <soapenv:Body>" +
+ " <!-- Comment After Body -->" +
+ " <typ:echo>" +
+ " <!-- Comment Before Parameters -->" +
+ " <stringA>FirstString</stringA>" +
+ " <stringB>SecondString</stringB>" +
+ " <!-- Comment After Parameters -->" +
+ " </typ:echo>" +
+ " <!-- Comment Before Close Body -->" +
+ " </soapenv:Body>" +
+ " <!-- Comment Before Close Envelope -->" +
+ "</soapenv:Envelope>";
+
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = msgFactory.createMessage(null, new
ByteArrayInputStream(message.getBytes()));
+
+ SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
+ SOAPConnection con = conFactory.createConnection();
+ SOAPMessage resMessage = con.call(soapMessage, "http://" +
getServerHost() + ":8080/jaxrpc-jbws1610");
+
+ Name name = new
NameImpl("echoResponse","ns1","http://org.jboss.test.ws/jbws1610/types");
+ SOAPElement soapElement =
(SOAPElement)resMessage.getSOAPBody().getChildElements(name).next();
+ assertEquals("echoResponse",
soapElement.getElementName().getLocalName());
+ }
}
Modified:
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/TestHandler.java
===================================================================
---
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/TestHandler.java 2007-06-25
09:49:01 UTC (rev 3710)
+++
branches/jbossws-1.2.0.GA_JBWS-1610/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1610/TestHandler.java 2007-06-25
11:33:22 UTC (rev 3711)
@@ -36,6 +36,7 @@
import javax.xml.soap.SOAPPart;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.soap.TextImpl;
/**
*
@@ -68,8 +69,8 @@
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
SOAPPart part = soapMessage.getSOAPPart();
- SOAPEnvelope evnelope = part.getEnvelope();
- SOAPBody body = evnelope.getBody();
+ SOAPEnvelope envelope = part.getEnvelope();
+ SOAPBody body = envelope.getBody();
MessageFactory msgFact = MessageFactory.newInstance();
@@ -78,20 +79,32 @@
SOAPEnvelope newEnvelope = newPart.getEnvelope();
SOAPBody newBody = newEnvelope.getBody();
- SOAPElement lookup = (SOAPElement)body.getChildElements().next();
+ SOAPElement lookup = null;
+ Iterator it = body.getChildElements();
+ while (lookup == null && it.hasNext())
+ {
+ Object next = it.next();
+ if (next instanceof SOAPElement)
+ lookup = (SOAPElement)next;
+ }
Name lookupQN = lookup.getElementName();
SOAPElement lookupEl = newBody.addChildElement(lookupQN);
- Iterator it = lookup.getChildElements();
+ it = lookup.getChildElements();
while (it.hasNext())
{
- SOAPElement element = (SOAPElement)it.next();
+ Object next = it.next();
+ if (next instanceof TextImpl)
+ continue;
+
+ SOAPElement element = (SOAPElement)next;
Name name = element.getElementName();
SOAPElement newElement = lookupEl.addChildElement(name);
newElement.setValue(letters + element.getValue() + letters);
}
+ envelope.removeContents();
part.setContent(newPart.getContent());
soapMessage.saveChanges();