[jbossws-commits] JBossWS SVN: r14243 - in shared-testsuite/trunk/src/test: java/org/jboss/test/ws/jaxws and 4 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed May 4 17:53:54 EDT 2011
Author: alessio.soldano at jboss.com
Date: 2011-05-04 17:53:53 -0400 (Wed, 04 May 2011)
New Revision: 14243
Added:
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/AuthorizationHandler.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/Endpoint.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointHandler.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointImpl.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/HandlerChainTestCase.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/LogHandler.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/RoutingHandler.java
shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/jaxws-handlers-server.xml
shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/
shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/
shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/jaxws-endpoint-config.xml
shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/web.xml
Modified:
shared-testsuite/trunk/src/test/ant-import/build-jars-jaxws.xml
Log:
[JBWS-3282] Adding testcase for handlers in jaxws configuration
Modified: shared-testsuite/trunk/src/test/ant-import/build-jars-jaxws.xml
===================================================================
--- shared-testsuite/trunk/src/test/ant-import/build-jars-jaxws.xml 2011-05-04 21:53:28 UTC (rev 14242)
+++ shared-testsuite/trunk/src/test/ant-import/build-jars-jaxws.xml 2011-05-04 21:53:53 UTC (rev 14243)
@@ -1053,6 +1053,19 @@
<include name="wsdl/**" />
</webinf>
</war>
+
+ <!-- jaxws-jbws3282 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws3282.war" webxml="${tests.output.dir}/test-resources/jaxws/jbws3282/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws3282/EndpointImpl.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws3282/Endpoint.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws3282/*Handler.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws3282/jaxws-handlers-server.xml"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/jbws3282/WEB-INF">
+ <include name="**/*" />
+ </webinf>
+ </war>
<!-- jaxws-endpoint-servlet -->
<war warfile="${tests.output.dir}/test-libs/jaxws-endpoint-servlet.war" manifest="${tests.output.dir}/test-resources/jaxws/endpoint/META-INF/MANIFEST.MF"
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/AuthorizationHandler.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/AuthorizationHandler.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/AuthorizationHandler.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+public class AuthorizationHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(AuthorizationHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("AuthorizationHandlerInbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|AuthIn");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("AuthorizationHandlerOutbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|AuthOut");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/Endpoint.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/Endpoint.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/Endpoint.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name="Endpoint")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Endpoint
+{
+ public String echo(String input);
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointHandler.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointHandler.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointHandler.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+public class EndpointHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(EndpointHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("EndpointHandlerInbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|EpIn");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("EndpointHandlerOutbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|EpOut");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointImpl.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointImpl.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/EndpointImpl.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.annotation.EndpointConfig;
+
+ at WebService(name="Endpoint")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom Endpoint")
+ at HandlerChain(file = "jaxws-handlers-server.xml") // relative path from the class file
+public class EndpointImpl
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(EndpointImpl.class);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ log.info("echo: " + input);
+ return input + "|endpoint";
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/HandlerChainTestCase.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/HandlerChainTestCase.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/HandlerChainTestCase.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Test the handlers (pre/post) declaration in jaxws endpoint configuration
+ *
+ * https://issues.jboss.org/browse/JBWS-3282
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 03-May-2011
+ */
+public class HandlerChainTestCase extends JBossWSTest
+{
+ private static final String targetNS = "http://jbws3282.jaxws.ws.test.jboss.org/";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(HandlerChainTestCase.class, "jaxws-jbws3282.war");
+ }
+
+ public void testHandlerChain() throws Exception
+ {
+ QName serviceName = new QName(targetNS, "EndpointImplService");
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-jbws3282/TestService?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+
+ String resStr = port.echo("Kermit");
+ assertEquals("Kermit|RoutIn|AuthIn|EpIn|LogIn|endpoint|LogOut|EpOut|AuthOut|RoutOut", resStr);
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/LogHandler.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/LogHandler.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/LogHandler.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+public class LogHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(LogHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = getFailsafeSOAPHeader(soapMessage);
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("LogHandlerInbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|LogIn");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = getFailsafeSOAPHeader(soapMessage);
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("LogHandlerOutbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|LogOut");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+
+ private SOAPHeader getFailsafeSOAPHeader(SOAPMessage soapMessage) throws SOAPException
+ {
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ if (soapHeader == null)
+ {
+ soapHeader = soapMessage.getSOAPPart().getEnvelope().addHeader();
+ }
+ return soapHeader;
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/RoutingHandler.java
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/RoutingHandler.java (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/RoutingHandler.java 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jbws3282;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+public class RoutingHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(RoutingHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("RoutingHandlerInbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|RoutIn");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+// SOAPFactory soapFactory = SOAPFactory.newInstance();
+// Name headerName = soapFactory.createName("RoutingHandlerOutbound", "ns1", "http://somens");
+// SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
+// she.setValue("true");
+
+ SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
+ String value = soapElement.getValue();
+ soapElement.setValue(value + "|RoutOut");
+ }
+ catch (SOAPException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ return true;
+ }
+}
Added: shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/jaxws-handlers-server.xml
===================================================================
--- shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/jaxws-handlers-server.xml (rev 0)
+++ shared-testsuite/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws3282/jaxws-handlers-server.xml 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <handler>
+ <handler-name> EndpointHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.jbws3282.EndpointHandler </handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
\ No newline at end of file
Added: shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/jaxws-endpoint-config.xml (rev 0)
+++ shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/jaxws-endpoint-config.xml 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
+
+ <endpoint-config>
+ <config-name>Custom Endpoint</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:handler>
+ <javaee:handler-name>Log Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.test.ws.jaxws.jbws3282.LogHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:handler>
+ <javaee:handler-name>Authorization Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.test.ws.jaxws.jbws3282.AuthorizationHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Routing Handler</javaee:handler-name>
+ <javaee:handler-class>org.jboss.test.ws.jaxws.jbws3282.RoutingHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ </endpoint-config>
+
+</jaxws-config>
\ No newline at end of file
Added: shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/web.xml
===================================================================
--- shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/web.xml (rev 0)
+++ shared-testsuite/trunk/src/test/resources/jaxws/jbws3282/WEB-INF/web.xml 2011-05-04 21:53:53 UTC (rev 14243)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws3282.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
More information about the jbossws-commits
mailing list