Author: darran.lofthouse(a)jboss.com
Date: 2008-09-23 12:55:10 -0400 (Tue, 23 Sep 2008)
New Revision: 8205
Added:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2319TestCase.java
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java
Removed:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.java
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/LogicalHandler.java
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/EndpointImpl.java
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml
Log:
Test changes and the fix.
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -46,13 +46,13 @@
/**
* A representation of a node (element) in an XML document.
- * This interface extnends the standard DOM Node interface with methods for getting and
setting the value of a node,
+ * This interface extends the standard DOM Node interface with methods for getting and
setting the value of a node,
* for getting and setting the parent of a node, and for removing a node.
*
* When creating a DOM2 tree the objects maintained by the tree are
<code>org.w3c.dom.Node</code> objects
* and not <code>javax.xml.soap.Node</code> objects.
* <p/>
- * This implementation schields the client from the the underlying DOM2 tree, returning
<code>javax.xml.soap.Node</code>
+ * This implementation shields the client from the the underlying DOM2 tree, returning
<code>javax.xml.soap.Node</code>
* objects.
*
* @author Thomas.Diesler(a)jboss.org
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -66,7 +66,7 @@
public SOAPElement addChildElement(SOAPElement child) throws SOAPException
{
log.trace("addChildElement: " + child.getElementName());
-
+
if ((child instanceof SOAPBodyElement) == false)
child = convertToBodyElement(child);
@@ -192,7 +192,7 @@
}
return bodyElement;
}
-
+
public Node appendChild(Node newChild) throws DOMException
{
log.trace("appendChild: " + newChild.getNodeName());
@@ -236,22 +236,33 @@
Iterator childElements = getChildElements();
+ SOAPElementImpl childElement = null;
+
+ while (childElements.hasNext() == true)
+ {
+ Object current = childElements.next();
+ if (current instanceof SOAPElementImpl)
+ childElement = (SOAPElementImpl)current;
+ }
+
// zero child elements?
- if (!childElements.hasNext())
+ if (childElement == null)
throw new SOAPException("Cannot find SOAPBodyElement");
- SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
-
// more than one child element?
- if (childElements.hasNext())
- throw new SOAPException("Multiple SOAPBodyElement");
+ while (childElements.hasNext() == true)
+ {
+ Object current = childElements.next();
+ if (current instanceof SOAPElementImpl)
+ throw new SOAPException("Multiple SOAPBodyElement");
+ }
if (childElement instanceof SOAPContentElement)
{
// cause expansion to DOM
SOAPContentElement contentElement = (SOAPContentElement)childElement;
// TODO change visibility of SOAPContentElement.expandToDOM() to package?
- contentElement.getPayload();
+ contentElement.hasChildNodes();
}
// child SOAPElement is removed as part of this process
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2008-09-23
16:55:10 UTC (rev 8205)
@@ -372,6 +372,18 @@
<include name="jboss-web.xml"/>
</webinf>
</war>
+
+ <!-- jaxws-jbws2319 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2319.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2319/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2319/*.class"/>
+ <exclude
name="org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.class"/>
+ <include
name="org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2319/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war"
webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/EndpointImpl.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/EndpointImpl.java 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/EndpointImpl.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -24,19 +24,23 @@
import javax.jws.HandlerChain;
import javax.jws.WebService;
+import org.jboss.logging.Logger;
+
/**
* Test Endpoint implementation.
*
* @author darran.lofthouse(a)jboss.com
* @since 23rd September 2008
*/
-@WebService(name = "Endpoint", targetNamespace =
"http://ws.jboss.org/jbws2285", endpointInterface =
"org.jboss.test.ws.jaxws.jbws2319.Endpoint")
+@WebService(name = "Endpoint", targetNamespace =
"http://ws.jboss.org/jbws2319", endpointInterface =
"org.jboss.test.ws.jaxws.jbws2319.Endpoint")
@HandlerChain(file = "server-handlers.xml")
public class EndpointImpl implements Endpoint
{
+ private static final Logger log = Logger.getLogger(EndpointImpl.class);
public String echo(final String message)
{
+ log.info("Value to echo '" + message + "'");
return message;
}
Deleted:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.java 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxws.jbws2319;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.Service;
-
-import junit.framework.Test;
-
-import org.jboss.ws.core.soap.NodeImpl;
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * [JBWS-2319] ClassCastException: org.jboss.ws.core.soap.TextImpl
- * in SOAPBody.extractContentAsDocument();
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 23rd September 2008
- * @see
https://jira.jboss.org/jira/browse/JBWS-2319
- */
-public class JBWS2285TestCase extends JBossWSTest
-{
-
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws2285/";
-
- private static Endpoint port;
-
- public static Test suite() throws Exception
- {
- return new JBossWSTestSetup(JBWS2285TestCase.class,
"jaxws-jbws2285.war");
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- QName serviceName = new
QName("http://ws.jboss.org/jbws2285",
"EndpointImplService");
-
- Service service = Service.create(wsdlURL, serviceName);
- port = service.getPort(Endpoint.class);
- }
-
- public void testCall() throws Exception
- {
- final String message = "Hello!!";
- String response = port.echo(message);
-
- // The logical handler should have replaced the incoming String.
- assertEquals("XXX", response);
- }
-
- public void testSOAPConnection() throws Exception
- {
- SOAPMessage reqMsg = getRequestMessage();
- URL epURL = new URL(TARGET_ENDPOINT_ADDRESS);
- SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
- SOAPMessage resMsg = con.call(reqMsg, epURL);
- SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
-
- String response = "";
-
- SOAPBody body = resEnv.getBody();
- Iterator it = body.getChildElements(new
QName("http://ws.jboss.org/jbws2285", "echoResponse"));
- Node node = (Node)it.next();
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node current = nodes.item(i);
- if (current.getNodeName().equals("return"))
- {
- response = ((NodeImpl)current).getValue();
- }
- }
-
- // The logical handler should have replaced the incoming String.
- assertEquals("XXX", response);
- }
-
- private SOAPMessage getRequestMessage() throws SOAPException, IOException
- {
- URL reqMessage =
getResourceFile("jaxws/jbws2285/request-message.xml").toURL();
- MessageFactory msgFactory = MessageFactory.newInstance();
-
- SOAPMessage reqMsg = msgFactory.createMessage(null, reqMessage.openStream());
- return reqMsg;
- }
-
-}
Copied:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2319TestCase.java
(from rev 8203,
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.java)
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2319TestCase.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/JBWS2319TestCase.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2319;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.ws.core.soap.NodeImpl;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * [JBWS-2319] ClassCastException: org.jboss.ws.core.soap.TextImpl
+ * in SOAPBody.extractContentAsDocument();
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 23rd September 2008
+ * @see
https://jira.jboss.org/jira/browse/JBWS-2319
+ */
+public class JBWS2319TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws2319/";
+
+ private static Endpoint port;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2319TestCase.class,
"jaxws-jbws2319.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new
QName("http://ws.jboss.org/jbws2319",
"EndpointImplService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(Endpoint.class);
+ }
+
+ public void testCall() throws Exception
+ {
+ final String message = "Hello!!";
+ String response = port.echo(message);
+
+ // The logical handler should have replaced the incoming String.
+ assertEquals("XXX", response);
+ }
+
+ public void testSOAPConnection() throws Exception
+ {
+ SOAPMessage reqMsg = getRequestMessage();
+ URL epURL = new URL(TARGET_ENDPOINT_ADDRESS);
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, epURL);
+ SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
+
+ String response = "";
+
+ SOAPBody body = resEnv.getBody();
+ Iterator it = body.getChildElements(new
QName("http://ws.jboss.org/jbws2319", "echoResponse"));
+ Node node = (Node)it.next();
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+ if (current.getNodeName().equals("return"))
+ {
+ response = ((NodeImpl)current).getValue();
+ }
+ }
+
+ // The logical handler should have replaced the incoming String.
+ assertEquals("XXX", response);
+ }
+
+ private SOAPMessage getRequestMessage() throws SOAPException, IOException
+ {
+ URL reqMessage =
getResourceFile("jaxws/jbws2319/request-message.xml").toURL();
+ MessageFactory msgFactory = MessageFactory.newInstance();
+
+ SOAPMessage reqMsg = msgFactory.createMessage(null, reqMessage.openStream());
+ return reqMsg;
+ }
+
+}
Deleted:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/LogicalHandler.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/LogicalHandler.java 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/LogicalHandler.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxws.jbws2319;
-
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.LogicalMessage;
-import javax.xml.ws.handler.LogicalMessageContext;
-import javax.xml.ws.handler.MessageContext;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.wsf.common.DOMWriter;
-import org.jboss.wsf.test.GenericLogicalHandler;
-
-/**
- * Logical handler implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 23rd September 2008
- */
-public class LogicalHandler extends GenericLogicalHandler
-{
-
- private static final Logger log = Logger.getLogger(LogicalHandler.class);
-
- @Override
- protected boolean handleInbound(final MessageContext msgContext)
- {
- log.info("handleInbound()");
-
- LogicalMessageContext lmc = (LogicalMessageContext)msgContext;
- LogicalMessage message = lmc.getMessage();
-
- Object payload = message.getPayload();
-
- if (payload instanceof DOMSource == false)
- {
- throw new WSException("Test requires DOMSource payload");
- }
-
- DOMSource domPayload = (DOMSource)payload;
- Node node = domPayload.getNode();
-
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node current = nodes.item(i);
- if ("arg0".equals(current.getLocalName()))
- {
- current.setTextContent("XXX");
- }
- }
-
- log.info(DOMWriter.printNode(node, false));
-
- return true;
- }
-
-}
Copied:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java
(from rev 8203,
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/LogicalHandler.java)
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java 2008-09-23
16:55:10 UTC (rev 8205)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2319;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElementFactory;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.LogicalMessageContext;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Logical handler implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 23rd September 2008
+ */
+public class SOAPHandler extends GenericSOAPHandler<LogicalMessageContext>
+{
+
+ private static final Logger log = Logger.getLogger(SOAPHandler.class);
+
+ @Override
+ protected boolean handleInbound(final MessageContext msgContext)
+ {
+ log.info("handleInbound()");
+
+ try
+ {
+ SOAPMessageContext smc = (SOAPMessageContext)msgContext;
+ SOAPMessage message = smc.getMessage();
+
+ SOAPBody body = message.getSOAPBody();
+ Document document = body.extractContentAsDocument();
+ Node node = document;
+
+ log.info(DOMWriter.printNode(node, false));
+
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+
+ NodeList childNodes = current.getChildNodes();
+ for (int j = 0; j < childNodes.getLength(); j++)
+ {
+ Node currentChildNode = childNodes.item(j);
+ if ("arg0".equals(currentChildNode.getLocalName()))
+ {
+ log.info("Replacing " + currentChildNode.getTextContent() +
" with XXX");
+ currentChildNode.setTextContent("XXX");
+ }
+ }
+ }
+
+ log.info(DOMWriter.printNode(node, false));
+
+ // Add document back as removed by call to 'extractContentAsDocument()'
+ body.addDocument(document);
+ message.saveChanges();
+ }
+ catch (SOAPException e)
+ {
+ throw new WSException("Error in Handler", e);
+ }
+
+ log.info("Finished");
+ return true;
+ }
+
+}
Modified:
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml 2008-09-23
14:11:17 UTC (rev 8204)
+++
stack/native/branches/dlofthouse/JBWS-2319/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml 2008-09-23
16:55:10 UTC (rev 8205)
@@ -7,8 +7,8 @@
<handler-chain>
<handler>
- <handler-name> LogicalServerHandler </handler-name>
- <handler-class> org.jboss.test.ws.jaxws.jbws2319.LogicalHandler
</handler-class>
+ <handler-name> SOAPServerHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.jbws2319.SOAPHandler
</handler-class>
</handler>
</handler-chain>