gdaniels 2002/10/16 08:03:04 Modified: java/test/soap TestHeaderAttrs.java java/src/org/apache/axis/message SOAPHeader.java java/src/org/apache/axis/soap SOAPConstants.java SOAP12Constants.java SOAP11Constants.java Added: java/test/soap12 TestHeaderAttrs.java Log: Remove more SOAP 1.1 dependencies, add getNextRoleURI() API to SOAPVersion and implementations, and update header attrs test to use soapVersion to get "next" role URI. Revision Changes Path 1.9 +3 -7 xml-axis/java/test/soap/TestHeaderAttrs.java Index: TestHeaderAttrs.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/soap/TestHeaderAttrs.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- TestHeaderAttrs.java 15 Oct 2002 21:15:44 -0000 1.8 +++ TestHeaderAttrs.java 16 Oct 2002 15:03:04 -0000 1.9 @@ -56,8 +56,6 @@ package test.soap; import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.framework.Test; import org.apache.axis.AxisFault; import org.apache.axis.Constants; import org.apache.axis.SimpleTargetedChain; @@ -73,8 +71,6 @@ import java.util.Random; -import test.RPCDispatch.Data; - import org.apache.axis.client.Service; /** @@ -147,7 +143,7 @@ assertTrue("Bad result from test", runTest(badHeader, false)); // 2. MU header to NEXT -> should fail - badHeader.setActor(Constants.URI_SOAP11_NEXT_ACTOR); + badHeader.setActor(soapVersion.getNextRoleURI()); badHeader.setMustUnderstand(true); // Test (should produce MU failure) @@ -170,7 +166,7 @@ */ public void testNonMUBadHeader() throws Exception { - badHeader.setActor(Constants.URI_SOAP11_NEXT_ACTOR); + badHeader.setActor(soapVersion.getNextRoleURI()); badHeader.setMustUnderstand(false); assertTrue("Non-MU bad header to next actor returned bad result!", @@ -187,7 +183,7 @@ */ public void testGoodHeader() throws Exception { - goodHeader.setActor(Constants.URI_SOAP11_NEXT_ACTOR); + goodHeader.setActor(soapVersion.getNextRoleURI()); assertTrue("Good header with next actor returned bad result!", runTest(goodHeader, true)); } 1.1 xml-axis/java/test/soap12/TestHeaderAttrs.java Index: TestHeaderAttrs.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ /** * @author Glen Daniels ([EMAIL PROTECTED]) */ package test.soap12; import org.apache.axis.soap.SOAPConstants; public class TestHeaderAttrs extends test.soap.TestHeaderAttrs { public TestHeaderAttrs(String name) { super(name); } /** * Use SOAP version 1.2. Otherwise, run the same tests. */ public void setUp() throws Exception { soapVersion = SOAPConstants.SOAP12_CONSTANTS; super.setUp(); } } 1.62 +18 -7 xml-axis/java/src/org/apache/axis/message/SOAPHeader.java Index: SOAPHeader.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- SOAPHeader.java 15 Oct 2002 21:15:42 -0000 1.61 +++ SOAPHeader.java 16 Oct 2002 15:03:04 -0000 1.62 @@ -115,8 +115,10 @@ if(parent == null) throw new IllegalArgumentException(Messages.getMessage("nullParent00")); try { + SOAPEnvelope env = (SOAPEnvelope)parent; // cast to force exception if wrong type - super.setParentElement((SOAPEnvelope)parent); + super.setParentElement(env); + setEnvelope(env); } catch (Throwable t) { throw new SOAPException(t); } @@ -167,10 +169,12 @@ Vector getHeadersByActor(ArrayList actors) { Vector results = new Vector(); Iterator i = headers.iterator(); + String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI(); while (i.hasNext()) { SOAPHeaderElement header = (SOAPHeaderElement)i.next(); + // Always process NEXT's, and then anything else in our list - if (Constants.URI_SOAP11_NEXT_ACTOR.equals(header.getActor()) || + if (nextActor.equals(header.getActor()) || (actors != null && actors.contains(header.getActor()))) { results.add(header); } @@ -213,14 +217,20 @@ if (mc != null) { if (header != null) { String actor = header.getActor(); + + // Always respect "next" role + String nextActor = + getEnvelope().getSOAPConstants().getNextRoleURI(); + if (nextActor.equals(actor)) + return header; + SOAPService soapService = mc.getService(); if (soapService != null) { ArrayList actors = mc.getService().getActors(); if ((actor != null) && - !Constants.URI_SOAP11_NEXT_ACTOR.equals(actor) && - (actors == null || !actors.contains(actor))) { + (actors == null || !actors.contains(actor))) { header = null; - } + } } } } @@ -270,6 +280,8 @@ Vector v = new Vector(); Enumeration e = headers.elements(); SOAPHeaderElement header; + String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI(); + while (e.hasMoreElements()) { header = (SOAPHeaderElement)e.nextElement(); if (header.getNamespaceURI().equals(namespace) && @@ -286,8 +298,7 @@ } String actor = header.getActor(); - if ((actor != null) && - !Constants.URI_SOAP11_NEXT_ACTOR.equals(actor) && + if ((actor != null) && !nextActor.equals(actor) && (actors == null || !actors.contains(actor))) { continue; } 1.7 +5 -0 xml-axis/java/src/org/apache/axis/soap/SOAPConstants.java Index: SOAPConstants.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAPConstants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SOAPConstants.java 24 Aug 2002 18:18:18 -0000 1.6 +++ SOAPConstants.java 16 Oct 2002 15:03:04 -0000 1.7 @@ -109,4 +109,9 @@ * Obtain the MIME content type */ public String getContentType(); + + /** + * Obtain the "next" role/actor URI + */ + public String getNextRoleURI(); } 1.8 +7 -0 xml-axis/java/src/org/apache/axis/soap/SOAP12Constants.java Index: SOAP12Constants.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAP12Constants.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SOAP12Constants.java 14 Oct 2002 13:11:17 -0000 1.7 +++ SOAP12Constants.java 16 Oct 2002 15:03:04 -0000 1.8 @@ -111,4 +111,11 @@ public String getContentType() { return "application/soap+xml; charset=utf-8"; } + + /** + * Obtain the "next" role/actor URI + */ + public String getNextRoleURI() { + return Constants.URI_SOAP12_NEXT_ACTOR; + } } 1.7 +7 -0 xml-axis/java/src/org/apache/axis/soap/SOAP11Constants.java Index: SOAP11Constants.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAP11Constants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SOAP11Constants.java 23 Aug 2002 19:07:19 -0000 1.6 +++ SOAP11Constants.java 16 Oct 2002 15:03:04 -0000 1.7 @@ -106,4 +106,11 @@ public String getContentType() { return "text/xml; charset=utf-8"; } + + /** + * Obtain the "next" role/actor URI + */ + public String getNextRoleURI() { + return Constants.URI_SOAP11_NEXT_ACTOR; + } }