gdaniels 2002/12/04 12:12:05 Modified: java/src/org/apache/axis MessageContext.java java/src/org/apache/axis/client Call.java java/src/org/apache/axis/configuration SimpleProvider.java java/src/org/apache/axis/description ServiceDesc.java java/src/org/apache/axis/encoding SerializationContextImpl.java java/src/org/apache/axis/handlers/soap SOAPService.java java/src/org/apache/axis/i18n resource.properties java/src/org/apache/axis/message SOAPBody.java java/src/org/apache/axis/server server-config.wsdd java/test GenericLocalTest.java java/test/encoding TestArrayListConversions.java java/test/functional TestJWSGlobalTypes.java Added: java/test/encoding TestGlobalTypeMappings.java Log: Start a simple test to confirm global type mappings work in both RPC and Document scenarios. Along the way, did a bunch of cleanup. * Make Call.setReturnClass() do more - in particular it now sets the return XML type if possible. This means you need to call addParameter() if using it, just like for setReturnType(). * Throw an IllegalArgumentException if trying to pass null to SOAPService.setEngine() * Make sure we delegate to the engine's registry in setEngine() * Remove the separate fields for Use and Style in the MC, as discussed on the list earlier. The MC now uses the versions in the OperationDesc/ServiceDesc. * Default Use based on Style, so if you set Style=DOCUMENT for a ServiceDesc, the default Use changes to LITERAL automatically. * Remove unused stuff in server-config.wsdd per Doug's email * Make sure we don't bother with multirefs if the MessageContext isEncoded() method returns false (SerializationContextImpl) * Style-enable GenericLocalTest * Random bits of cleanup (unused imports, etc) Revision Changes Path 1.125 +21 -38 xml-axis/java/src/org/apache/axis/MessageContext.java Index: MessageContext.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v retrieving revision 1.124 retrieving revision 1.125 diff -u -r1.124 -r1.125 --- MessageContext.java 9 Oct 2002 19:06:28 -0000 1.124 +++ MessageContext.java 4 Dec 2002 20:12:03 -0000 1.125 @@ -186,9 +186,7 @@ */ private String username = null; private String password = null; - private Style operationStyle = Style.RPC; - private Use operationUse = Use.ENCODED; - private String encodingStyle = operationUse.getEncoding(); + private String encodingStyle = Use.ENCODED.getEncoding(); private boolean useSOAPAction = false; private String SOAPActionURI = null; @@ -248,8 +246,6 @@ ServiceDesc desc = serviceHandler.getInitializedServiceDesc(this); if (desc != null) { - setOperationStyle(desc.getStyle()); - setOperationUse(desc.getUse()); if (desc.getStyle() != Style.DOCUMENT) { possibleOperations = desc.getOperationsByQName(qname); } else { @@ -434,7 +430,7 @@ * Encoding */ public boolean isEncoded() { - return (operationUse == Use.ENCODED); + return (getOperationUse() == Use.ENCODED); //return soapConstants.getEncodingURI().equals(encodingStyle); } @@ -644,11 +640,9 @@ serviceHandler = sh; if (sh != null) { targetService = sh.getName(); - SOAPService service = (SOAPService)sh; + SOAPService service = sh; TypeMappingRegistry tmr = service.getTypeMappingRegistry(); setTypeMappingRegistry(tmr); - setOperationStyle(service.getStyle()); - setOperationUse(service.getUse()); // styles are not "soap version aware" so compensate... setEncodingStyle(service.getUse().getEncoding()); @@ -798,19 +792,6 @@ } setMaintainSession(((Boolean) value).booleanValue()); } - else if (name.equals(Call.OPERATION_STYLE_PROPERTY)) { - if (!(value instanceof String)) { - throw new IllegalArgumentException( - Messages.getMessage("badProp00", new String[] { - name, "java.lang.String", value.getClass().getName()})); - } - setOperationStyle(Style.getStyle((String)value, Style.DEFAULT)); - if (getOperationStyle() == Style.RPC) { - setOperationUse(Use.ENCODED); - } else if (getOperationStyle() == Style.DOCUMENT) { - setOperationUse(Use.LITERAL); - } - } else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) { if (!(value instanceof Boolean)) { throw new IllegalArgumentException( @@ -940,31 +921,33 @@ } // getPassword /** - * Set the operation style. - */ - public void setOperationStyle(Style operationStyle) { - this.operationStyle = operationStyle; - } // setOperationStyle - - /** * Get the operation style. */ public Style getOperationStyle() { - return operationStyle; - } // getOperationStyle + if (currentOperation != null) { + return currentOperation.getStyle(); + } - /** - * Set the operation use. - */ - public void setOperationUse(Use operationUse) { - this.operationUse = operationUse; - } // setOperationUse + if (serviceHandler != null) { + return serviceHandler.getStyle(); + } + + return Style.RPC; + } // getOperationStyle /** * Get the operation use. */ public Use getOperationUse() { - return operationUse; + if (currentOperation != null) { + return currentOperation.getUse(); + } + + if (serviceHandler != null) { + return serviceHandler.getUse(); + } + + return Use.ENCODED; } // getOperationUse /** 1.193 +13 -2 xml-axis/java/src/org/apache/axis/client/Call.java Index: Call.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- Call.java 3 Nov 2002 16:51:49 -0000 1.192 +++ Call.java 4 Dec 2002 20:12:03 -0000 1.193 @@ -1087,6 +1087,19 @@ * @param cls the desired return class. */ public void setReturnClass(Class cls) { + if (operationSetManually) { + throw new RuntimeException( + Messages.getMessage("operationAlreadySet")); + } + + if (operation == null) + operation = new OperationDesc(); + + operation.setReturnClass(cls); + TypeMapping tm = getTypeMapping(); + operation.setReturnType(tm.getTypeQName(cls)); + parmAndRetReq = true; + returnJavaType = cls; } @@ -2273,8 +2286,6 @@ operation.setStyle(getOperationStyle()); operation.setUse(getOperationUse()); } - msgContext.setOperationStyle(getOperationStyle()); - msgContext.setOperationUse(getOperationUse()); if (useSOAPAction) { msgContext.setUseSOAPAction(true); 1.8 +2 -2 xml-axis/java/src/org/apache/axis/configuration/SimpleProvider.java Index: SimpleProvider.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/SimpleProvider.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SimpleProvider.java 11 Jun 2002 14:53:52 -0000 1.7 +++ SimpleProvider.java 4 Dec 2002 20:12:03 -0000 1.8 @@ -70,7 +70,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.ArrayList; -import java.util.Set; /** * A SimpleProvider is an EngineConfiguration which contains a simple @@ -243,7 +242,8 @@ public void deployService(QName qname, SOAPService service) { services.put(qname, service); - service.setEngine(engine); + if (engine != null) + service.setEngine(engine); } public void deployService(String name, SOAPService service) 1.68 +10 -0 xml-axis/java/src/org/apache/axis/description/ServiceDesc.java Index: ServiceDesc.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- ServiceDesc.java 14 Oct 2002 20:02:21 -0000 1.67 +++ ServiceDesc.java 4 Dec 2002 20:12:03 -0000 1.68 @@ -116,6 +116,11 @@ private Style style = Style.RPC; private Use use = Use.ENCODED; + // Style and Use are related. By default, if Style==RPC, Use should be + // ENCODED. But if Style==DOCUMENT, Use should be LITERAL. So we want + // to keep the defaults synced until someone explicitly sets the Use. + private boolean useSet = false; + /** Implementation class */ private Class implClass = null; @@ -191,6 +196,10 @@ public void setStyle(Style style) { this.style = style; + if (!useSet) { + // Use hasn't been explicitly set, so track style + use = style == Style.RPC ? Use.ENCODED : Use.LITERAL; + } } /** @@ -202,6 +211,7 @@ } public void setUse(Use use) { + useSet = true; this.use = use; } 1.82 +2 -1 xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java Index: SerializationContextImpl.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- SerializationContextImpl.java 2 Dec 2002 19:12:12 -0000 1.81 +++ SerializationContextImpl.java 4 Dec 2002 20:12:04 -0000 1.82 @@ -681,7 +681,8 @@ // hashCode() and equals() methods have been overloaded to make two // Objects appear equal. - if (doMultiRefs && (value != forceSer) && !isPrimitive(value)) { + if (doMultiRefs && (msgContext == null || msgContext.isEncoded()) && + (value != forceSer) && !isPrimitive(value)) { if (multiRefIndex == -1) multiRefValues = new HashMap(); 1.89 +5 -0 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java Index: SOAPService.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- SOAPService.java 19 Nov 2002 23:28:08 -0000 1.88 +++ SOAPService.java 4 Dec 2002 20:12:04 -0000 1.89 @@ -276,7 +276,12 @@ */ public void setEngine(AxisEngine engine) { + if (engine == null) + throw new IllegalArgumentException( + Messages.getMessage("nullEngine")); + this.engine = engine; + getTypeMappingRegistry().delegate(engine.getTypeMappingRegistry()); } public AxisEngine getEngine() { 1.35 +1 -0 xml-axis/java/src/org/apache/axis/i18n/resource.properties Index: resource.properties =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- resource.properties 2 Dec 2002 19:12:12 -0000 1.34 +++ resource.properties 4 Dec 2002 20:12:04 -0000 1.35 @@ -1079,3 +1079,4 @@ cantLoadByecode=Unable to load bytecode for class "{0}" wsdlFileMissing=Unable to find WSDL file or resource {0} +nullEngine=Null engine passed to SOAPService.setEngine()! 1.35 +1 -1 xml-axis/java/src/org/apache/axis/message/SOAPBody.java Index: SOAPBody.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- SOAPBody.java 20 Nov 2002 03:13:42 -0000 1.34 +++ SOAPBody.java 4 Dec 2002 20:12:04 -0000 1.35 @@ -143,7 +143,7 @@ // Output this body element. } - // Output multi-refs + // Output multi-refs if appropriate context.outputMultiRefs(); // Output </SOAP-ENV:Body> 1.14 +1 -3 xml-axis/java/src/org/apache/axis/server/server-config.wsdd Index: server-config.wsdd =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/server-config.wsdd,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- server-config.wsdd 6 Sep 2002 01:21:08 -0000 1.13 +++ server-config.wsdd 4 Dec 2002 20:12:05 -0000 1.14 @@ -26,9 +26,7 @@ --> </globalConfiguration> - <handler type="java:org.apache.axis.providers.java.RPCProvider" name="RPCDispatcher"/> <handler type="java:org.apache.axis.handlers.http.URLMapper" name="URLMapper"/> - <handler type="java:org.apache.axis.providers.java.MsgProvider" name="MsgDispatcher"/> <handler type="java:org.apache.axis.transport.local.LocalResponder" name="LocalResponder"/> <handler type="java:org.apache.axis.handlers.SimpleAuthenticationHandler" name="Authenticate"/> @@ -53,7 +51,7 @@ <transport name="local"> <responseFlow> - <handler type="java:org.apache.axis.transport.local.LocalResponder"/> + <handler type="LocalResponder"/> </responseFlow> </transport> 1.2 +5 -2 xml-axis/java/test/GenericLocalTest.java Index: GenericLocalTest.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/GenericLocalTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- GenericLocalTest.java 1 Dec 2002 19:48:17 -0000 1.1 +++ GenericLocalTest.java 4 Dec 2002 20:12:05 -0000 1.2 @@ -61,6 +61,7 @@ import org.apache.axis.transport.local.LocalTransport; import org.apache.axis.configuration.SimpleProvider; import org.apache.axis.configuration.BasicServerConfig; +import org.apache.axis.enum.Style; import junit.framework.TestCase; /** @@ -129,7 +130,7 @@ * Convenience method to deploy ourselves as a service */ public void deploy() { - deploy("service", this.getClass()); + deploy("service", this.getClass(), Style.RPC); } /** @@ -139,10 +140,12 @@ * @param serviceName the name under which to deploy the service. * @param target class of the service. */ - public void deploy(String serviceName, Class target) { + public void deploy(String serviceName, Class target, Style style) { String className = target.getName(); SOAPService service = new SOAPService(new RPCProvider()); + service.setStyle(style); + service.setOption("className", className); service.setOption("allowedMethods", "*"); 1.22 +2 -1 xml-axis/java/test/encoding/TestArrayListConversions.java Index: TestArrayListConversions.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/encoding/TestArrayListConversions.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- TestArrayListConversions.java 6 Aug 2002 03:55:05 -0000 1.21 +++ TestArrayListConversions.java 4 Dec 2002 20:12:05 -0000 1.22 @@ -8,10 +8,10 @@ import org.apache.axis.server.AxisServer; import org.apache.axis.transport.local.LocalTransport; import org.apache.axis.configuration.SimpleProvider; -import org.apache.axis.encoding.DefaultTypeMappingImpl; import org.apache.axis.description.ServiceDesc; import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -124,6 +124,7 @@ l.add("This will be a SOAP Array then a Vector!"); call.setOperationName(new QName(SERVICE_NAME, "echoArray")); + call.addParameter("arg0", null, LinkedList.class, ParameterMode.IN); call.setReturnClass(Vector.class); Object ret = call.invoke(new Object[]{l}); assertEquals("Return wasn't a Vector!", Vector.class, ret.getClass()); 1.1 xml-axis/java/test/encoding/TestGlobalTypeMappings.java Index: TestGlobalTypeMappings.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/>. */ package test.encoding; import test.GenericLocalTest; import org.apache.axis.encoding.TypeMapping; import org.apache.axis.encoding.ser.BeanSerializerFactory; import org.apache.axis.encoding.ser.BeanDeserializerFactory; import org.apache.axis.enum.Style; import org.apache.axis.client.Call; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; /** * Confirm that global type mappings work in both RPC and Document * contexts. * * @author Glen Daniels ([EMAIL PROTECTED]) */ public class TestGlobalTypeMappings extends GenericLocalTest { private QName TYPE_QNAME = new QName("ns", "dataType"); public TestGlobalTypeMappings() { super("service"); } public TestGlobalTypeMappings(String s) { super(s); } protected void setUp() throws Exception { super.setUp(false); // don't deploy here TypeMapping tm = (TypeMapping)config.getTypeMappingRegistry(). getDefaultTypeMapping(); tm.register(Data.class, TYPE_QNAME, new BeanSerializerFactory(Data.class, TYPE_QNAME), new BeanDeserializerFactory(Data.class, TYPE_QNAME)); } public void testDocLit() throws Exception { deploy("service", this.getClass(), Style.WRAPPED); Call call = getCall(); call.setOperationStyle("wrapped"); call.setOperationUse("literal"); call.setEncodingStyle(""); call.registerTypeMapping(Data.class, TYPE_QNAME, new BeanSerializerFactory(Data.class, TYPE_QNAME), new BeanDeserializerFactory(Data.class, TYPE_QNAME)); call.setReturnClass(Data.class); call.addParameter("arg0", TYPE_QNAME, ParameterMode.IN); Data data = new Data(); data.stringMember = "doc lit test"; data.floatMember = new Float(451.0F); call.invoke("echoData", new Object [] { data }); } /** * Our service method. We'll deploy this several ways. * * @param data * @return */ public Data echoData(Data data) { return data; } } 1.5 +0 -1 xml-axis/java/test/functional/TestJWSGlobalTypes.java Index: TestJWSGlobalTypes.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/functional/TestJWSGlobalTypes.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestJWSGlobalTypes.java 11 Jun 2002 14:54:03 -0000 1.4 +++ TestJWSGlobalTypes.java 4 Dec 2002 20:12:05 -0000 1.5 @@ -1,7 +1,6 @@ /* * The Apache Software License, Version 1.1 * - * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. *