axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r773900 [1/3] - in /webservices/axis2/trunk/java/modules: jaxws-integration/ jaxws-integration/test-resources/wsdl/ jaxws-integration/test/org/apache/axis2/jaxws/sample/ jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/ j...
Date Tue, 12 May 2009 13:55:16 GMT
Author: rott
Date: Tue May 12 13:55:16 2009
New Revision: 773900

URL: http://svn.apache.org/viewvc?rev=773900&view=rev
Log:
Jira: AXIS2-4345 - improve performance for JAX-WS handlers when accessing or manipulating SOAP headers

Added:
    webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/HeadersHandler.wsdl
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HandlerTracker.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientHandlers.xml
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientLogicalHandler.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler2.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientTrackerHandler.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersHandlerFault_Exception.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersHandlerPortType.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersHandlerPortTypeImpl.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersHandlerService.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersHandlers.xml
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersServerLogicalHandler.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersServerProtocolHandler.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/META-INF/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/META-INF/HeadersHandler.wsdl
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/TestHeaders.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/Constants.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/SOAPHeadersAdapterTests.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SOAPHeadersAdapter.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=773900&r1=773899&r2=773900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Tue May 12 13:55:16 2009
@@ -273,6 +273,12 @@
                                     <classpath location="${compiled.classes.dir}"/>
                                     <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/AddNumbersHandler.wsdl"/>
                                 </java>
+                                <echo>Generating java from HeadersHandler.wsdl</echo>
+                                <java classname="com.sun.tools.xjc.Driver" fork="true">
+                                    <classpath refid="maven.runtime.classpath"/>
+                                    <classpath location="${compiled.classes.dir}"/>
+                                    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/HeadersHandler.wsdl"/>
+                                </java>
                                 <echo>Generating java from async_doclitwr.wsdl</echo>
                                 <java classname="com.sun.tools.xjc.Driver" fork="true">
                                     <classpath refid="maven.runtime.classpath"/>
@@ -387,12 +393,6 @@
                                     <classpath location="${compiled.classes.dir}"/>
                                     <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/rpclitenum.wsdl"/>
                                 </java>
-                                <echo>Generating java from AddNumbersHandler.wsdl</echo>
-                                <java classname="com.sun.tools.xjc.Driver" fork="true">
-                                    <classpath refid="maven.runtime.classpath"/>
-                                    <classpath location="${compiled.classes.dir}"/>
-                                    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/AddNumbersHandler.wsdl"/>
-                                </java>
                                 <echo>Generating java from rpclitstringarray.wsdl</echo>
                                 <java classname="com.sun.tools.xjc.Driver" fork="true">
                                     <classpath refid="maven.runtime.classpath"/>
@@ -970,6 +970,21 @@
                                      basedir="${pom.basedir}/target/test-classes/servicejars/AddNumbersHandlerService"
                                         />
                                 <delete dir="target/test-classes/servicejars/AddNumbersHandlerService"/>
+                                <copy toDir="target/test-classes/servicejars/HeadersHandlerService/">
+                                    <fileset dir="target/test-classes">
+                                        <include name="org/apache/axis2/jaxws/sample/headershandler/**"/>
+                                        <exclude
+                                                name="org/apache/axis2/jaxws/sample/headershandler/META-INF/services.xml"/>
+                                    </fileset>
+                                    <fileset dir="test/org/apache/axis2/jaxws/sample/headershandler">
+                                        <include name="META-INF/**"/>
+                                        <exclude name="META-INF/services.xml"/>
+                                    </fileset>
+                                </copy>
+                                <zip destfile="target/test-classes/servicejars/HeadersHandlerService.jar"
+                                     basedir="${pom.basedir}/target/test-classes/servicejars/HeadersHandlerService"
+                                        />
+                                <delete dir="target/test-classes/servicejars/HeadersHandlerService"/>
                                 <copy toDir="target/test-classes/servicejars/GreeterService/">
                                     <fileset dir="target/test-classes">
                                         <include name="org/apache/axis2/jaxws/sample/dlwmin/**"/>
@@ -1364,6 +1379,7 @@
                         <include>**/JAXBProviderTests.java</include>
                         <include>**/BareTests.java</include>
                         <include>**/AddNumbersHandlerTests.java</include>
+                        <include>**/HeadersHandlerTests.java</include>
                         <include>**/AddNumbersTests.java</include>
                         <include>**/DLWMinTests.java</include>
                         <include>**/FaultsServiceTests.java</include>

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/HeadersHandler.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/HeadersHandler.wsdl?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/HeadersHandler.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/HeadersHandler.wsdl Tue May 12 13:55:16 2009
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<definitions name="HeadersHandler" targetNamespace="http://org/test/headershandler"
+	xmlns:tns="http://org/test/headershandler" xmlns="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+
+	<types>
+		<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+			elementFormDefault="qualified" targetNamespace="http://org/test/headershandler">
+			<element name="headersHandlerResponse">
+				<complexType>
+					<sequence>
+						<element name="return" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="headersHandler">
+				<complexType>
+					<sequence>
+						<element name="arg0" type="xsd:int" />
+						<element name="arg1" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="HeadersHandlerFault">
+				<complexType>
+					<sequence>
+						<element name="faultInfo" type="xsd:string" />
+						<element name="message" type="xsd:string" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="oneWayInt">
+				<complexType>
+					<sequence>
+						<element name="arg0" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+		</xsd:schema>
+	</types>
+
+	<message name="headersHandler">
+		<part name="parameters" element="tns:headersHandler" />
+	</message>
+	<message name="headersHandlerResponse">
+		<part name="result" element="tns:headersHandlerResponse" />
+	</message>
+	<message name="headersHandlerFault">
+		<part name="HeadersHandlerFault" element="tns:HeadersHandlerFault" />
+	</message>
+	<message name="oneWayInt">
+		<part name="parameters" element="tns:oneWayInt" />
+	</message>
+
+	<portType name="HeadersHandlerPortType">
+		<operation name="headersHandler">
+			<input message="tns:headersHandler" name="add" />
+			<output message="tns:headersHandlerResponse" name="addResponse" />
+			<fault name="headersHandlerFault" message="tns:headersHandlerFault" />
+		</operation>
+		<operation name="oneWayInt">
+			<input message="tns:oneWayInt" />
+		</operation>
+	</portType>
+	<binding name="HeadersHandlerBinding" type="tns:HeadersHandlerPortType">
+		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+			style="document" />
+		<operation name="headersHandler">
+			
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+			<fault name="headersHandlerFault">
+				<soap:fault name="headersHandlerFault" use="literal" />
+			</fault>
+		</operation>
+		<operation name="oneWayInt">
+			
+			<input>
+				<soap:body use="literal" />
+			</input>
+		</operation>
+	</binding>
+	<service name="HeadersHandlerService">
+		<port name="HeadersHandlerPort" binding="tns:HeadersHandlerBinding">
+			<soap:address
+				location="http://localhost:9080/HeadersHandler/HeadersHandlerImplService" />
+		</port>
+	</service>
+</definitions>

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java Tue May 12 13:55:16 2009
@@ -0,0 +1,741 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.axis2.jaxws.TestLogger;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.sample.headershandler.HeadersClientTrackerHandler;
+import org.apache.axis2.jaxws.sample.headershandler.HeadersHandlerPortType;
+import org.apache.axis2.jaxws.sample.headershandler.HeadersHandlerService;
+import org.apache.axis2.jaxws.sample.headershandler.TestHeaders;
+import org.test.headershandler.HeadersHandlerResponse;
+
+/**
+ * @author rott
+ *
+ */
+public class HeadersHandlerTests extends AbstractTestCase {
+
+    String axisEndpoint = "http://localhost:6060/axis2/services/HeadersHandlerService.HeadersHandlerPortTypeImplPort";
+    
+    private static final String filelogname = "HeadersHandlerTests.log";
+
+    public static Test suite() {
+        return getTestSetup(new TestSuite(HeadersHandlerTests.class));
+    }
+    
+    protected void setUp() throws Exception {
+        deleteFile();
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        //deleteFile();
+        super.tearDown();
+    }
+
+    private void deleteFile() throws Exception {
+        File file = new File(filelogname);
+        file.delete();  // yes, delete for each retrieval, which should only happen once per test
+    }
+
+
+
+    public void testHeadersHandler() {
+        try {
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+
+            HeadersHandlerService service = new HeadersHandlerService();
+            HeadersHandlerPortType proxy = service.getHeadersHandlerPort();
+            BindingProvider p = (BindingProvider) proxy;
+            Map<String, Object> requestCtx = p.getRequestContext();
+            
+            requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+            
+            /*
+             * add several headers by way of HeadersAdapter property
+             */
+            String acoh1, acoh2, acoh3, acoh4, acoh5, acoh6;
+            SOAPFactory sf = SOAPFactory.newInstance();
+        	try {
+            	Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
+            	
+            	// QName used here should match the key for the list set on the requestCtx
+            	acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL1);
+            	
+            	// QName used here should match the key for the list set on the requestCtx
+            	acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+            	
+            	// QName used here should match the key for the list set on the requestCtx
+            	acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+            	
+            	// QName used here should match the key for the list set on the requestCtx
+            	acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+            	
+            	// create additional header strings that will need to be checked:
+        		acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        		acoh6 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+            	
+            	List<String> list1 = new ArrayList<String>();
+            	list1.add(acoh1);
+            	list1.add(acoh2);
+            	
+            	List<String> list2 = new ArrayList<String>();
+            	list2.add(acoh3);
+            	list2.add(acoh4);
+            	
+            	requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+            	requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+            	requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+        	} catch (Throwable e) {
+        		fail(e.getMessage());
+        		return;
+        	}
+        	
+        	// some handlers decrement the value, so we can confirm SOAP body manipulation does not corrupt the headers
+        	int numOfHandlerHitsInFlow = 3;
+            
+            int intParam1 = 10;
+            int intParam2 = 10;
+            int total = proxy.headersHandler(intParam1, intParam2);
+            
+            assertEquals("Return value should be " + (intParam1 + intParam2 - numOfHandlerHitsInFlow) + " but was " + total ,
+                         (intParam1 + intParam2 - numOfHandlerHitsInFlow),
+                         total);
+            TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+            
+            /*
+             * I tried to give enough info below in the expected_calls list so you can tell what's
+             * being tested without having to look at handler code.  All header manipulation is
+             * done by SOAPHeadersAdapter.
+             * 
+             * TODO: I would very much like to have done some other means of
+             * header manipulation, but the Axis2 SAAJ module is lacking necessary implementation
+             * to do this with any reliability.
+             */
+            
+            String log = readLogFile();
+            String expected_calls =
+            		// client outbound
+                      "HeadersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh4+"\n"   // message manipulated after this action
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh2+"\n"                   
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler GET_HEADERS\n"
+                    + "HeadersClientProtocolHandler2 GET_HEADERS\n"
+                    // server inbound
+                    + "HeadersServerProtocolHandler GET_HEADERS\n"
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh5+"\n"   // message manipulated after this action
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh6+"\n"
+                    // server outbound
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersServerLogicalHandler ADDED_HEADER "+acoh1+"\n"   // message manipulated after this action
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CLOSE\n"
+                    + "HeadersServerProtocolHandler CLOSE\n"
+                    // client inbound
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 ADDED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler REMOVED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CLOSE\n"
+                    + "HeadersClientProtocolHandler CLOSE\n"
+                    + "HeadersClientLogicalHandler CLOSE\n";
+            
+            assertEquals(expected_calls, log);
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            TestLogger.logger.debug("ERROR", e);
+            fail(e.getMessage());
+        }
+        TestLogger.logger.debug("----------------------------------");
+    }
+    
+    public void testHeadersHandlerAsyncCallback() {
+        try {
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+
+            HeadersHandlerService service = new HeadersHandlerService();
+            HeadersHandlerPortType proxy = service.getHeadersHandlerPort();
+            BindingProvider p = (BindingProvider) proxy;
+            Map<String, Object> requestCtx = p.getRequestContext();
+            
+            requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+            
+            /*
+             * add several headers by way of HeadersAdapter property
+             */
+            String acoh1, acoh2, acoh3, acoh4, acoh5, acoh6;
+            SOAPFactory sf = SOAPFactory.newInstance();
+            try {
+                Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
+                
+                // QName used here should match the key for the list set on the requestCtx
+                acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL1);
+                
+                // QName used here should match the key for the list set on the requestCtx
+                acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+                
+                // QName used here should match the key for the list set on the requestCtx
+                acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+                
+                // QName used here should match the key for the list set on the requestCtx
+                acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+                
+                // create additional header strings that will need to be checked:
+                acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+                acoh6 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+                
+                List<String> list1 = new ArrayList<String>();
+                list1.add(acoh1);
+                list1.add(acoh2);
+                
+                List<String> list2 = new ArrayList<String>();
+                list2.add(acoh3);
+                list2.add(acoh4);
+                
+                requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+                requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+                requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+            } catch (Throwable e) {
+                fail(e.getMessage());
+                return;
+            }
+            
+            // some handlers decrement the value, so we can confirm SOAP body manipulation does not corrupt the headers
+            int numOfHandlerHitsInFlow = 3;
+            
+            int intParam1 = 10;
+            int intParam2 = 10;
+            
+            HeadersHandlerAsyncCallback callback = new HeadersHandlerAsyncCallback();
+            Future<?> future = proxy.headersHandlerAsync(intParam1, intParam2, callback);
+
+            while (!future.isDone()) {
+                Thread.sleep(1000);
+                TestLogger.logger.debug("Async invocation incomplete");
+            }
+
+            int total = callback.getResponseValue();
+            
+            
+            assertEquals("Return value should be " + (intParam1 + intParam2 - numOfHandlerHitsInFlow) + " but was " + total ,
+                         (intParam1 + intParam2 - numOfHandlerHitsInFlow),
+                         total);
+            TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+            
+            /*
+             * I tried to give enough info below in the expected_calls list so you can tell what's
+             * being tested without having to look at handler code.  All header manipulation is
+             * done by SOAPHeadersAdapter.
+             * 
+             * TODO: I would very much like to have done some other means of
+             * header manipulation, but the Axis2 SAAJ module is lacking necessary implementation
+             * to do this with any reliability.
+             */
+            
+            String log = readLogFile();
+            String expected_calls =
+                    // client outbound
+                      "HeadersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh4+"\n"   // message manipulated after this action
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh2+"\n"                   
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler GET_HEADERS\n"
+                    + "HeadersClientProtocolHandler2 GET_HEADERS\n"
+                    // server inbound
+                    + "HeadersServerProtocolHandler GET_HEADERS\n"
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh5+"\n"   // message manipulated after this action
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh6+"\n"
+                    // server outbound
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersServerLogicalHandler ADDED_HEADER "+acoh1+"\n"   // message manipulated after this action
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CLOSE\n"
+                    + "HeadersServerProtocolHandler CLOSE\n"
+                    // client inbound
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 ADDED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler REMOVED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CLOSE\n"
+                    + "HeadersClientProtocolHandler CLOSE\n"
+                    + "HeadersClientLogicalHandler CLOSE\n";
+            
+            assertEquals(expected_calls, log);
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+        TestLogger.logger.debug("----------------------------------");
+    }
+    
+    public void testHeadersHandlerServerInboundFault() {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+
+        HeadersHandlerService service = new HeadersHandlerService();
+        HeadersHandlerPortType proxy = service.getHeadersHandlerPort();
+        BindingProvider p = (BindingProvider) proxy;
+        Map<String, Object> requestCtx = p.getRequestContext();
+
+        requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+        /*
+         * add several headers by way of HeadersAdapter property
+         */
+        String acoh1, acoh2, acoh3, acoh4, acoh5, acoh6;
+        SOAPFactory sf;
+        try {
+            sf = SOAPFactory.newInstance();
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+            return;
+        }
+
+        Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL1);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+
+        // create additional header strings that will need to be checked:
+        acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        acoh6 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+
+        List<String> list1 = new ArrayList<String>();
+        list1.add(acoh1);
+        list1.add(acoh2);
+
+        List<String> list2 = new ArrayList<String>();
+        list2.add(acoh3);
+        list2.add(acoh4);
+
+        requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+        requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+        requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+
+        // some handlers decrement the value, so we can confirm SOAP body manipulation does not corrupt the headers
+        int numOfHandlerHitsInFlow = 3;
+
+        int intParam1 = 10;
+        int intParam2 = 66;
+            
+        try {
+            int total = proxy.headersHandler(intParam1, intParam2);
+            fail("headersHandler should have caused an exception, but did not.");
+            
+            /*
+             * I tried to give enough info below in the expected_calls list so you can tell what's
+             * being tested without having to look at handler code.  All header manipulation is
+             * done by SOAPHeadersAdapter.
+             * 
+             * TODO: I would very much like to have done some other means of
+             * header manipulation, but the Axis2 SAAJ module is lacking necessary implementation
+             * to do this with any reliability.
+             */
+            
+        } catch (Exception e) {
+            
+            String log = readLogFile();
+            String expected_calls =
+                    // client outbound
+                      "HeadersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh4+"\n"   // message manipulated after this action
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh2+"\n"                   
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler GET_HEADERS\n"
+                    + "HeadersClientProtocolHandler2 GET_HEADERS\n"
+                    // server inbound
+                    + "HeadersServerProtocolHandler GET_HEADERS\n"
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh5+"\n"   // message manipulated after this action
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh6+"\n"   // throws protocol exception
+                    // server outbound
+                    + "HeadersServerProtocolHandler HANDLE_FAULT_OUTBOUND\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CLOSE\n"
+                    + "HeadersServerProtocolHandler CLOSE\n"
+                    // client inbound
+                    + "HeadersClientProtocolHandler2 HANDLE_FAULT_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 REMOVED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler HANDLE_FAULT_INBOUND\n"
+                    + "HeadersClientLogicalHandler HANDLE_FAULT_INBOUND\n"   // getPayload called, just to exercise underlying code
+                    + "HeadersClientProtocolHandler2 CLOSE\n"
+                    + "HeadersClientProtocolHandler CLOSE\n"
+                    + "HeadersClientLogicalHandler CLOSE\n";
+            
+            assertEquals(expected_calls, log);
+            assertEquals("I don't like 66", e.getMessage());
+            
+        }
+        TestLogger.logger.debug("----------------------------------");
+    }
+    
+    
+    /*
+     * TODO: test is currently disabled due to exception:
+     * 
+     * Caused by: java.net.SocketException: Broken pipe
+     * at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:103)
+     * at java.net.SocketOutputStream.write(SocketOutputStream.java:147)
+     * at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:109)
+     * at org.apache.http.impl.io.ChunkedOutputStream.flushCacheWithAppend(ChunkedOutputStream.java:117)
+     * at org.apache.http.impl.io.ChunkedOutputStream.write(ChunkedOutputStream.java:166)
+     * at org.apache.axis2.transport.http.server.AxisHttpResponseImpl$AutoCommitOutputStream.write(AxisHttpResponseImpl.java:231)
+     * at com.ctc.wstx.io.UTF8Writer.write(UTF8Writer.java:139)
+     * at com.ctc.wstx.sw.BufferingXmlWriter.flushBuffer(BufferingXmlWriter.java:1103)
+     * at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:213)
+     * at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311)
+     * ... 12 more
+     * 
+     * Currently, the server side returns the inbound message when a handler.handleMessage
+     * method returns 'false'.  This may be a misinterpretation of the jaxws spec.
+     * When the response flow is fixed, remove this comment, and remove the '_' from the
+     * test method name to enable it.
+     */
+    public void _testHeadersHandlerServerInboundFlowReversal() {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+
+        HeadersHandlerService service = new HeadersHandlerService();
+        HeadersHandlerPortType proxy = service.getHeadersHandlerPort();
+        BindingProvider p = (BindingProvider) proxy;
+        Map<String, Object> requestCtx = p.getRequestContext();
+
+        requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+        /*
+         * add several headers by way of HeadersAdapter property
+         */
+        String acoh1, acoh2, acoh3, acoh4, acoh5, acoh6;
+        SOAPFactory sf;
+        try {
+            sf = SOAPFactory.newInstance();
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+            return;
+        }
+
+        Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL1);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+
+        // QName used here should match the key for the list set on the requestCtx
+        acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+
+        // create additional header strings that will need to be checked:
+        acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        acoh6 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+
+        List<String> list1 = new ArrayList<String>();
+        list1.add(acoh1);
+        list1.add(acoh2);
+
+        List<String> list2 = new ArrayList<String>();
+        list2.add(acoh3);
+        list2.add(acoh4);
+
+        requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+        requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+        requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+
+        int intParam1 = 10;
+        int intParam2 = 33;
+            
+        try {
+            int total = proxy.headersHandler(intParam1, intParam2);
+        } catch (Exception e) {
+            /*
+             * I tried to give enough info below in the expected_calls list so you can tell what's
+             * being tested without having to look at handler code.  All header manipulation is
+             * done by SOAPHeadersAdapter.
+             * 
+             * TODO: I would very much like to have done some other means of
+             * header manipulation, but the Axis2 SAAJ module is lacking necessary implementation
+             * to do this with any reliability.
+             */
+            
+            
+            String log = readLogFile();
+            String expected_calls =
+                    // client outbound
+                      "HeadersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh4+"\n"   // message manipulated after this action
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh2+"\n"                   
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler GET_HEADERS\n"
+                    + "HeadersClientProtocolHandler2 GET_HEADERS\n"
+                    // server inbound
+                    + "HeadersServerProtocolHandler GET_HEADERS\n"
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh2+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CHECKED_HEADER "+acoh6+"\n"
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh5+"\n"   // message manipulated after this action
+                    + "HeadersServerLogicalHandler REMOVED_HEADER "+acoh6+"\n"   // returns false
+                    // server outbound
+                    + "HeadersServerProtocolHandler HANDLE_MESSAGE_OUTBOUND\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler CHECKED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler REMOVED_HEADER "+acoh1+"\n"
+                    + "HeadersServerProtocolHandler ADDED_HEADER "+acoh5+"\n"
+                    + "HeadersServerLogicalHandler CLOSE\n"
+                    + "HeadersServerProtocolHandler CLOSE\n"
+                    // client inbound
+                    + "HeadersClientProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler2 CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler2 ADDED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientProtocolHandler REMOVED_HEADER "+acoh5+"\n"
+                    + "HeadersClientProtocolHandler ADDED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler CHECKED_HEADER "+acoh4+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh3+"\n"
+                    + "HeadersClientLogicalHandler REMOVED_HEADER "+acoh4+"\n"
+                    + "HeadersClientProtocolHandler2 CLOSE\n"
+                    + "HeadersClientProtocolHandler CLOSE\n"
+                    + "HeadersClientLogicalHandler CLOSE\n";
+            
+            assertEquals("I don't like 33", e.getMessage());
+            assertEquals(expected_calls, log);
+            
+        }
+        TestLogger.logger.debug("----------------------------------");
+    }
+    
+    /*
+     * The intent of making the SOAPHeadersAdapter available to handlers is that they
+     * use it as an alternative to SAAJ.  We have protection built in to prevent handler
+     * implementations from doing both.  This method tests for that.
+     */
+    public void testHeadersHandlerTracker() {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        try {
+
+            HeadersHandlerService service = new HeadersHandlerService();
+            HeadersHandlerPortType proxy = service.getHeadersHandlerPort();
+            BindingProvider p = (BindingProvider) proxy;
+            List<Handler> handlers = p.getBinding().getHandlerChain();
+            if (handlers == null)
+                handlers = new ArrayList<Handler>();
+            handlers.add(new HeadersClientTrackerHandler());
+            p.getBinding().setHandlerChain(handlers);
+            Map<String, Object> requestCtx = p.getRequestContext();
+
+            requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+            
+            int total = proxy.headersHandler(1, 1);
+            fail("Should have received a WebServiceException, but did not.");
+
+        } catch (Exception e) {
+            assertTrue(e instanceof WebServiceException);
+        }
+        TestLogger.logger.debug("----------------------------------");
+    }
+    
+    
+    /*
+     * A callback implementation that can be used to collect the exceptions
+     */
+    class HeadersHandlerAsyncCallback implements AsyncHandler<HeadersHandlerResponse> {
+
+        private Exception exception;
+        private int retVal;
+
+        public void handleResponse(Response<HeadersHandlerResponse> response) {
+            try {
+                TestLogger.logger.debug("HeadersHandlerAsyncCallback.handleResponse() was called");
+                HeadersHandlerResponse r = response.get();
+                TestLogger.logger.debug("No exception was thrown from Response.get()");
+                retVal = r.getReturn();
+            } catch (Exception e) {
+                TestLogger.logger.debug("An exception was thrown: " + e.getClass());
+                exception = e;
+            }
+        }
+
+        public int getResponseValue() {
+            return retVal;
+        }
+
+        public Exception getException() {
+            return exception;
+        }
+    }
+    
+    
+    private String readLogFile() {
+        try {
+            FileReader fr = new FileReader(filelogname);
+            BufferedReader inputStream = new BufferedReader(fr);
+            String line = null;
+            String ret = null;
+            while ((line = inputStream.readLine()) != null) {
+                if (ret == null) {
+                    ret = "";
+                }
+                ret = ret.concat(line + "\n");
+            }
+            fr.close();
+            return ret;
+        } catch (FileNotFoundException fnfe) {
+            // it's possible the test does not actually call any handlers and therefore
+            // no file would have been written.  The test should account for this by
+            // assertNull on the return value from here
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+            fail(ioe.getMessage());
+        }
+        return null;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HandlerTracker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HandlerTracker.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HandlerTracker.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HandlerTracker.java Tue May 12 13:55:16 2009
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample.headershandler;
+
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public class HandlerTracker {
+
+    private static final String filelogname = "HeadersHandlerTests.log";
+    
+    private String classname;
+    
+    private static final String CLOSE = "CLOSE";
+    private static final String GET_HEADERS = "GET_HEADERS";
+    private static final String HANDLE_FAULT_INBOUND = "HANDLE_FAULT_INBOUND";
+    private static final String HANDLE_MESSAGE_INBOUND = "HANDLE_MESSAGE_INBOUND";
+    private static final String HANDLE_FAULT_OUTBOUND = "HANDLE_FAULT_OUTBOUND";
+    private static final String HANDLE_MESSAGE_OUTBOUND = "HANDLE_MESSAGE_OUTBOUND";
+    private static final String POST_CONSTRUCT = "POST_CONSTRUCT";
+    private static final String PRE_DESTROY = "PRE_DESTROY";
+    private static final String ADDED_HEADER = "ADDED_HEADER";
+    private static final String CHECKED_HEADER = "CHECKED_HEADER";
+    private static final String REMOVED_HEADER = "REMOVED_HEADER";
+    
+    // should pass classname for "name"
+    public HandlerTracker(String name) {
+        classname = name;
+    }
+    
+    public void postConstruct() {
+        log_to_file(POST_CONSTRUCT);
+    }
+    
+    public void preDestroy() {
+        log_to_file(PRE_DESTROY);
+    }
+    
+    public void close() {
+        log_to_file(CLOSE);
+    }
+
+    public void getHeaders() {
+        log_to_file(GET_HEADERS);
+    }
+    
+    public void addHeader(String xmlHeader) {
+    	log_to_file(ADDED_HEADER + " " + xmlHeader);
+    }
+    
+    public void checkHeader(String xmlHeader) {
+    	log_to_file(CHECKED_HEADER + " " + xmlHeader);
+    }
+    
+    public void removedHeader(String xmlHeader) {
+    	log_to_file(REMOVED_HEADER + " " + xmlHeader);
+    }
+    
+    public void handleFault(boolean outbound) {
+        if (outbound) {
+            log_to_file(HANDLE_FAULT_OUTBOUND);
+        } else {
+            log_to_file(HANDLE_FAULT_INBOUND);
+        }
+    }
+
+    public void handleMessage(boolean outbound) {
+        if (outbound) {
+            log_to_file(HANDLE_MESSAGE_OUTBOUND);
+        } else {
+            log_to_file(HANDLE_MESSAGE_INBOUND);
+        }
+    }
+    
+    public void log(String msg, boolean outbound) {
+        log_to_file(msg + " " + (outbound ? "OUTBOUND" : "INBOUND"));
+    }
+    
+    /*
+     * we have to open and close the file every time we write
+     * as other handler method calls may be interleaved with this one
+     */
+    private void log_to_file(String msg) {
+        try {
+            FileWriter fw = new FileWriter(filelogname, true);
+            fw.write(classname + " " + msg + "\n");
+            fw.flush();
+            fw.close();
+        } catch (Exception e) {
+        }
+    }
+    
+    public void log_exception_to_file(String filename, Throwable e) {
+    	try {
+    		FileWriter fw = new FileWriter(filename, true);
+    		StringWriter sw = new StringWriter();
+    	    PrintWriter pw = new PrintWriter(sw);
+    	    e.printStackTrace(pw);
+    	    fw.write(sw.toString());
+    	    fw.flush();
+    	    fw.close();
+    	} catch (Exception ex) {
+    	}
+    }
+    
+    public void log_to_my_file(String filename, String msg) {
+    	try {
+    		FileWriter fw = new FileWriter(filename, true);
+    	    fw.write(msg);
+    	    fw.flush();
+    	    fw.close();
+    	} catch (Exception ex) {
+    	}
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientHandlers.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientHandlers.xml?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientHandlers.xml (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientHandlers.xml Tue May 12 13:55:16 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+
+	<jws:handler-chain name="HeadersClientHandlerChain">
+		<jws:handler>
+			<jws:handler-class>org.apache.axis2.jaxws.sample.headershandler.HeadersClientProtocolHandler</jws:handler-class>
+		</jws:handler>
+		<jws:handler>
+			<jws:handler-class>org.apache.axis2.jaxws.sample.headershandler.HeadersClientLogicalHandler</jws:handler-class>
+		</jws:handler>
+		<jws:handler>
+			<jws:handler-class>org.apache.axis2.jaxws.sample.headershandler.HeadersClientProtocolHandler2</jws:handler-class>
+		</jws:handler>
+	</jws:handler-chain>
+	
+</jws:handler-chains>
+

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientLogicalHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientLogicalHandler.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientLogicalHandler.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientLogicalHandler.java Tue May 12 13:55:16 2009
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample.headershandler;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringBufferInputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.LogicalMessage;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.jaxws.handler.LogicalMessageContext;
+
+public class HeadersClientLogicalHandler implements
+        javax.xml.ws.handler.LogicalHandler<LogicalMessageContext> {
+
+	private HandlerTracker tracker = new HandlerTracker(HeadersClientLogicalHandler.class.getSimpleName());
+	private TestHeaders headerUtil = new TestHeaders(this.getClass());
+	
+    public void close(MessageContext messagecontext) {
+    	tracker.close();
+    }
+
+    public boolean handleFault(LogicalMessageContext messagecontext) {
+    	Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+    	tracker.handleFault(outbound);
+    	if (!outbound) {
+    	    // this is the third client inbound hit
+    	    
+    	    // calling getPayload just to exercise the code:
+    	    messagecontext.getMessage().getPayload();
+    	}
+        return true;
+    }
+
+    public boolean handleMessage(LogicalMessageContext messagecontext) {
+        Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+        tracker.handleMessage(outbound);
+        if (outbound) { // outbound request on the client
+
+        	// this is the first client outbound handler hit
+        	
+            // turn off special property that logs ability to use
+            // both SOAPHeadersAdapter and SAAJ in a single handler method:
+            messagecontext.put(org.apache.axis2.jaxws.handler.Constants.JAXWS_HANDLER_TRACKER, false);
+            
+        	// let's check for all the headers we expect, remove a few, and manipulate the message payload
+        	
+        	Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
+        	headerUtil.confirmHeadersAdapterList(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders, 2);
+
+        	// expecting four header elements under two different QNames
+
+        	List<String> list1 = requestHeaders.get(TestHeaders.ACOH1_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH1_HEADER_QNAME, list1, 2);
+        	String acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL1);
+        	headerUtil.compareHeaderStrings(acoh1, list1.get(0));
+        	tracker.checkHeader(list1.get(0));
+        	// also:
+        	String acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+        	headerUtil.compareHeaderStrings(acoh2, list1.get(1));
+        	tracker.checkHeader(list1.get(1));
+        	
+        	List<String> list2 = requestHeaders.get(TestHeaders.ACOH2_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH2_HEADER_QNAME, list2, 2);
+        	String acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+        	headerUtil.compareHeaderStrings(acoh3, list2.get(0));
+        	tracker.checkHeader(list2.get(0));
+        	// also:
+        	String acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+        	headerUtil.compareHeaderStrings(acoh4, list2.get(1));
+        	tracker.checkHeader(list2.get(1));
+
+        	// remove header from list 1
+        	list1.remove(0);
+        	tracker.removedHeader(acoh1);
+        	// list1 is not a "live" list, so we need to put it back in
+        	requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+        	// remove all of list 2
+        	tracker.removedHeader(acoh3);
+        	tracker.removedHeader(acoh4);
+        	requestHeaders.remove(TestHeaders.ACOH2_HEADER_QNAME);
+        	
+        	// the requestHeaders object is a "live" list, so no need to do this:
+        	//messagecontext.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+
+        	// The 'get' on the requestHeaders map triggers a toString() on the underlying OM structure for the header element.
+        	// We want to make sure the parser was not closed prematurely, so...we do a getPayload() below on the message.
+        	// This causes a parse and build up of SAAJ, confirming the parser was not prematurely closed.
+
+        	// manipulate the payload just to be thorough
+        	LogicalMessage msg = messagecontext.getMessage();
+        	String st = getStringFromSourcePayload(msg.getPayload());
+        	String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) - 1);
+        	st = replaceFirstArg(st, txt);
+        	msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
+
+        } else {
+        	// TODO implement some inbound stuff
+        	
+        	// this is the third client inbound hit
+
+            LogicalMessage msg = messagecontext.getMessage();
+            String st = getStringFromSourcePayload(msg.getPayload());
+
+            if (st.contains("33")) {
+            
+                Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_INBOUND_SOAP_HEADERS);
+                headerUtil.confirmHeadersAdapterList(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders, 1);
+
+                // expecting two header elements under two QNames
+
+                /*
+                 * these headers need to be removed because this is a return path taken by a 
+                 * server handler that returned 'false' from a handleMessage call.  This means the original
+                 * outbound message was returned as-is, and JAXB will get confused if we leave
+                 * header elements on the Envelope.
+                 */
+
+                List<String> list2 = requestHeaders.get(TestHeaders.ACOH2_HEADER_QNAME);
+                headerUtil.confirmList(TestHeaders.ACOH2_HEADER_QNAME, list2, 2);
+                String acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+                headerUtil.compareHeaderStrings(acoh3, list2.get(0));
+                tracker.checkHeader(list2.get(0));
+                String acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+                headerUtil.compareHeaderStrings(acoh4, list2.get(1));
+                tracker.checkHeader(list2.get(1));
+
+                // remove list1
+                requestHeaders.remove(TestHeaders.ACOH2_HEADER_QNAME);
+                tracker.removedHeader(acoh3);
+                tracker.removedHeader(acoh4);
+                
+                // currently, the server runtime is returning the original client outbound message (see JAXWS 9.3.2.1), but
+                // once we exit this handler, the message will be passed to JAXB, and it won't like it because it's not
+                // the WSDL-specified response message.  In the interest of testing, however, let's do this, and make sure
+                // the junit test handles it and checks the calls into the handler flow anyway:
+                throw new WebServiceException("I don't like 33");
+
+            }
+        	
+        }
+        return true;
+    }
+
+    private static String getFirstArg(String payloadString) {
+        StringTokenizer st = new StringTokenizer(payloadString, ">");
+        st.nextToken(); // skip first token.
+        st.nextToken(); // skip second
+        String tempString = st.nextToken();
+        String returnString = new StringTokenizer(tempString, "<").nextToken();
+        return returnString;
+    }
+
+    private static String replaceFirstArg(String payloadString, String newArg) {
+        String firstArg = getFirstArg(payloadString);
+        payloadString = payloadString.replaceFirst(firstArg, newArg);
+        return payloadString;
+    }
+
+    private static String getStringFromSourcePayload(Source payload) {
+        try {
+
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer trans = factory.newTransformer();
+
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            StreamResult result = new StreamResult(baos);
+
+            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+            trans.transform(payload, result);
+
+            return new String(baos.toByteArray());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler.java Tue May 12 13:55:16 2009
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample.headershandler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.axis2.Constants;
+
+public class HeadersClientProtocolHandler implements
+        javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> {
+
+	private HandlerTracker tracker = new HandlerTracker(HeadersClientProtocolHandler.class.getSimpleName());
+	private TestHeaders headerUtil = new TestHeaders(this.getClass());
+	
+    public void close(MessageContext messagecontext) {
+    	tracker.close();
+    }
+
+    public boolean handleFault(SOAPMessageContext messagecontext) {
+    	Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+    	tracker.handleFault(outbound);
+    	if (!outbound) {
+    	    // this is the second client inbound handler hit
+        
+    	    // expecting 0 headers
+    	    
+    	    Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_INBOUND_SOAP_HEADERS);
+    	    headerUtil.confirmHeadersAdapterList(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders, 0);
+    	}
+        return true;
+    }
+
+    public Set getHeaders() {
+    	tracker.getHeaders();
+        return null;
+    }
+
+    public boolean handleMessage(SOAPMessageContext messagecontext) {
+        Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+        tracker.handleMessage(outbound);
+        if (outbound) {
+
+        	// this is the second client outbound handler hit
+        	
+        	Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
+        	headerUtil.confirmHeadersAdapterList(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders, 1);
+
+        	// expecting one header element
+        	
+        	List<String> list1 = requestHeaders.get(TestHeaders.ACOH1_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH1_HEADER_QNAME, list1, 1);
+        	String acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+        	headerUtil.compareHeaderStrings(acoh1, list1.get(0));
+        	tracker.checkHeader(list1.get(0));
+
+        	/*
+        	 * TODO:  would rather do the below type of testing so a header is added by some means other than
+        	 * SOAPHeadersAdapter, but Axis2 SAAJ implementation appears be be lacking some basic support here.
+        	 * Under Axis2 SAAJ, a header is inserted that has no text node underneath:  <ns:blarg someheader />
+        	 */
+        	//  SOAPElement acoh2 = TestHeaders.createHeaderSOAPElement(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        	//  messagecontext.getMessage().getSOAPHeader().addChildElement(acoh2);
+
+        	/*
+        	 * TODO: instead, we'll do this:
+        	 */
+        	String acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        	List<String> acoh2list = new ArrayList<String>();
+        	acoh2list.add(acoh2);
+        	requestHeaders.put(TestHeaders.ACOH3_HEADER_QNAME, acoh2list);
+        	messagecontext.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders);
+        	tracker.addHeader(acoh2.toString());
+
+        }
+        else {  // client inbound response
+        	
+        	// this is the second client inbound handler hit
+
+        	Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_INBOUND_SOAP_HEADERS);
+        	headerUtil.confirmHeadersAdapterList(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders, 2);
+
+        	// expecting two header elements under two QNames
+        	
+        	List<String> list1 = requestHeaders.get(TestHeaders.ACOH3_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH3_HEADER_QNAME, list1, 1);
+        	String acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        	headerUtil.compareHeaderStrings(acoh5, list1.get(0));
+        	tracker.checkHeader(list1.get(0));
+        	
+        	List<String> list2 = requestHeaders.get(TestHeaders.ACOH2_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH2_HEADER_QNAME, list2, 1);
+        	String acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+        	headerUtil.compareHeaderStrings(acoh3, list2.get(0));
+        	tracker.checkHeader(list2.get(0));
+        	
+        	// remove list1
+        	requestHeaders.remove(TestHeaders.ACOH3_HEADER_QNAME);
+        	tracker.removedHeader(acoh5);
+        	
+        	// add header to list2
+        	String acoh4 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL4);
+        	list2.add(acoh4);
+        	tracker.addHeader(acoh4);
+        	
+        	// list2 is not a "live" list, so...
+        	requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+
+        }
+        return true;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler2.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler2.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler2.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientProtocolHandler2.java Tue May 12 13:55:16 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample.headershandler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+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.apache.axis2.Constants;
+
+public class HeadersClientProtocolHandler2 implements
+        javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> {
+
+	private HandlerTracker tracker = new HandlerTracker(HeadersClientProtocolHandler2.class.getSimpleName());
+	private TestHeaders headerUtil = new TestHeaders(this.getClass());
+	
+    public void close(MessageContext messagecontext) {
+    	tracker.close();
+    }
+
+    public boolean handleFault(SOAPMessageContext messagecontext) {
+    	Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+    	tracker.handleFault(outbound);
+    	if (!outbound) {
+            // this is the first client inbound handler hit
+            
+            Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_INBOUND_SOAP_HEADERS);
+            headerUtil.confirmHeadersAdapterList(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders, 1);
+
+            // expecting one header element
+            
+            List<String> list1 = requestHeaders.get(TestHeaders.ACOH3_HEADER_QNAME);
+            headerUtil.confirmList(TestHeaders.ACOH3_HEADER_QNAME, list1, 1);
+            String acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+            headerUtil.compareHeaderStrings(acoh5, list1.get(0));
+            tracker.checkHeader(list1.get(0));
+            
+            tracker.removedHeader(acoh5);
+            requestHeaders.remove(TestHeaders.ACOH3_HEADER_QNAME);
+    	}
+        return true;
+    }
+
+    public Set getHeaders() {
+    	tracker.getHeaders();
+        return null;
+    }
+
+    public boolean handleMessage(SOAPMessageContext messagecontext) {
+        Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+        tracker.handleMessage(outbound);
+        if (outbound) {
+
+        	// this is the third client outbound handler hit
+
+        	Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
+        	headerUtil.confirmHeadersAdapterList(Constants.JAXWS_OUTBOUND_SOAP_HEADERS, requestHeaders, 2);
+
+        	// expecting two header elements under two different QNames
+        	
+        	List<String> list1 = requestHeaders.get(TestHeaders.ACOH1_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH1_HEADER_QNAME, list1, 1);
+        	String acoh1 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME, TestHeaders.CONTENT_SMALL2);
+        	headerUtil.compareHeaderStrings(acoh1, list1.get(0));
+        	tracker.checkHeader(list1.get(0));
+
+        	List<String> list2 = requestHeaders.get(TestHeaders.ACOH3_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH3_HEADER_QNAME, list2, 1);
+        	String acoh2 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        	headerUtil.compareHeaderStrings(acoh2, list2.get(0));
+        	tracker.checkHeader(list2.get(0));
+
+        }
+        else {  // client inbound response
+        	
+        	// this is the first client inbound handler hit
+        	
+        	Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_INBOUND_SOAP_HEADERS);
+        	headerUtil.confirmHeadersAdapterList(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders, 1);
+
+        	// expecting one header element
+        	
+        	List<String> list1 = requestHeaders.get(TestHeaders.ACOH3_HEADER_QNAME);
+        	headerUtil.confirmList(TestHeaders.ACOH3_HEADER_QNAME, list1, 1);
+        	String acoh5 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME, TestHeaders.CONTENT_LARGE);
+        	headerUtil.compareHeaderStrings(acoh5, list1.get(0));
+        	tracker.checkHeader(list1.get(0));
+        	
+        	// add header
+        	String acoh3 = TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME, TestHeaders.CONTENT_SMALL3);
+        	List<String> acoh2list = new ArrayList<String>();
+        	acoh2list.add(acoh3);
+        	requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, acoh2list);
+        	messagecontext.put(Constants.JAXWS_INBOUND_SOAP_HEADERS, requestHeaders);
+        	tracker.addHeader(acoh3.toString());
+        }
+        return true;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientTrackerHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientTrackerHandler.java?rev=773900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientTrackerHandler.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/headershandler/HeadersClientTrackerHandler.java Tue May 12 13:55:16 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample.headershandler;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.axis2.Constants;
+
+public class HeadersClientTrackerHandler implements
+        javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> {
+    
+    public void close(MessageContext messagecontext) {
+    }
+
+    public boolean handleFault(SOAPMessageContext messagecontext) {
+        return true;
+    }
+
+    public Set getHeaders() {
+        return null;
+    }
+
+    public boolean handleMessage(SOAPMessageContext messagecontext) {
+        Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+        if (outbound) {
+
+            // this is the first client outbound handler hit
+            
+            Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
+
+            // this should generate an exception.  We have protection built in to prevent using both
+            // the SOAPHeadersAdapter and SAAJ in the same handler method
+            
+            List<String> list1 = requestHeaders.get(TestHeaders.ACOH1_HEADER_QNAME);
+
+            try {
+                messagecontext.getMessage().getSOAPHeader();
+            } catch (SOAPException e) {
+                throw new ProtocolException(e);
+            }
+
+        }
+        else {  // client inbound response
+        }
+        return true;
+    }
+
+}



Mime
View raw message