gdaniels 02/04/23 09:25:39
Modified: java/samples/message MessageService.java
java/samples/misc TestClient.java
java/src/org/apache/axis/description ServiceDesc.java
java/src/org/apache/axis/message RPCElement.java
java/src/org/apache/axis/providers/java MsgProvider.java
java/src/org/apache/axis/utils Admin.java
java/test/encoding PackageTests.java
Added: java/test/encoding TestOmittedValues.java
Log:
* Fix http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8193
* Add unit test for omitted value == null
* Remove search for method with MessageContext argument from
MsgProvider, and fix the services that used to use it.
* Javadoc cleanup
Revision Changes Path
1.2 +1 -1 xml-axis/java/samples/message/MessageService.java
Index: MessageService.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/message/MessageService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessageService.java 17 Dec 2001 00:57:41 -0000 1.1
+++ MessageService.java 23 Apr 2002 16:25:38 -0000 1.2
@@ -5,7 +5,7 @@
import java.util.Vector ;
public class MessageService {
- public Element[] echoElements(MessageContext msgC, Vector elems) {
+ public Element[] echoElements(Vector elems) {
Element[] result = new Element[elems.size()];
for ( int i = 0 ; i < elems.size() ; i++ )
1.17 +1 -1 xml-axis/java/samples/misc/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/misc/TestClient.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TestClient.java 8 Feb 2002 22:14:11 -0000 1.16
+++ TestClient.java 23 Apr 2002 16:25:38 -0000 1.17
@@ -84,7 +84,7 @@
* Send a hardcoded message to the server, and print the response.
*
* @param args the command line arguments (mainly for specifying URL)
- * @param service an optional service argument, which will be used for
+ * @param op an optional service argument, which will be used for
* specifying the transport-level service
*/
public static String doTest (String args[], String op) throws Exception {
1.20 +3 -2 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ServiceDesc.java 19 Apr 2002 14:03:14 -0000 1.19
+++ ServiceDesc.java 23 Apr 2002 16:25:38 -0000 1.20
@@ -675,12 +675,13 @@
// Make an OperationDesc, fill in common stuff
OperationDesc operation = new OperationDesc();
operation.setName(method.getName());
+ String defaultNS = "";
if (namespaceMappings != null && !namespaceMappings.isEmpty()) {
// If we have a default namespace mapping, require callers to
// use that namespace.
- String defaultNS = (String)namespaceMappings.get(0);
- operation.setElementQName(new QName(defaultNS, method.getName()));
+ defaultNS = (String)namespaceMappings.get(0);
}
+ operation.setElementQName(new QName(defaultNS, method.getName()));
operation.setMethod(method);
Class retClass = method.getReturnType();
operation.setReturnClass(retClass);
1.55 +1 -1 xml-axis/java/src/org/apache/axis/message/RPCElement.java
Index: RPCElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- RPCElement.java 23 Apr 2002 03:54:26 -0000 1.54
+++ RPCElement.java 23 Apr 2002 16:25:38 -0000 1.55
@@ -174,7 +174,7 @@
for (int i = 0; i < operations.length; i++) {
OperationDesc operation = operations[i];
- if (operation.getNumInParams() == numParams) {
+ if (operation.getNumInParams() >= numParams) {
// Set the operation so the RPCHandler can get at it
rpcHandler.setOperation(operation);
try {
1.24 +1 -44
xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java
Index: MsgProvider.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- MsgProvider.java 20 Feb 2002 18:59:21 -0000 1.23
+++ MsgProvider.java 23 Apr 2002 16:25:39 -0000 1.24
@@ -57,7 +57,6 @@
import org.apache.axis.Handler;
import org.apache.axis.MessageContext;
-import org.apache.axis.AxisFault;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.utils.JavaUtils;
@@ -66,7 +65,6 @@
import org.w3c.dom.Element;
import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
import java.util.Vector;
/**
@@ -84,7 +82,6 @@
SOAPEnvelope reqEnv,
SOAPEnvelope resEnv,
JavaClass jc,
-
Object obj)
throws Exception
{
@@ -115,9 +112,7 @@
Vector bodies = reqEnv.getBodyElements();
SOAPBodyElement reqBody = reqEnv.getFirstBody();
NoSuchMethodException exp2 = null ;
- Object anElement =
- clsLoader.loadClass("org.w3c.dom.Element");
-
+
doc = reqBody.getAsDOM().getOwnerDocument();
Vector newBodies = new Vector();
@@ -154,28 +149,6 @@
catch( NoSuchMethodException exp ) {exp2 = exp;}
if ( method == null ) {
- // Try again with a msgContext first
- /////////////////////////////////////////////////////////////////
- argClasses = new Class[2];
- argObjects = new Object[2];
- argClasses[0] =
clsLoader.loadClass("org.apache.axis.MessageContext");
- argClasses[1] = clsLoader.loadClass("java.util.Vector");
- argObjects[0] = msgContext ;
- argObjects[1] = bodies ;
-
- try {
- method = jc.getJavaClass().getMethod( methodName, argClasses );
- Element[] result = (Element[]) method.invoke( obj, argObjects
);
- if ( result != null ) {
- for ( int i = 0 ; i < result.length ; i++ )
- resEnv.addBodyElement( new SOAPBodyElement(result[i]));
- }
- return ;
- }
- catch( NoSuchMethodException exp ) {exp2 = exp;}
- }
-
- if ( method == null ) {
// Try the the simplest case first - just Document as the param
/////////////////////////////////////////////////////////////////
argClasses = new Class[1];
@@ -183,22 +156,6 @@
argClasses[0] = clsLoader.loadClass("org.w3c.dom.Document");
argObjects[0] = doc ;
- try {
- method = jc.getJavaClass().getMethod( methodName, argClasses );
- }
- catch( NoSuchMethodException exp ) {exp2 = exp;}
- }
-
- if ( method == null ) {
- // Ok, no match - so now add MessageContext as the first param
- // and try it again
- ///////////////////////////////////////////////////////////////
- argClasses = new Class[2];
- argObjects = new Object[2];
- argClasses[0] =
clsLoader.loadClass("org.apache.axis.MessageContext");
- argClasses[1] = clsLoader.loadClass("org.w3c.dom.Document");
- argObjects[0] = msgContext ;
- argObjects[1] = doc ;
try {
method = jc.getJavaClass().getMethod( methodName, argClasses );
}
1.107 +2 -1 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- Admin.java 29 Mar 2002 15:05:21 -0000 1.106
+++ Admin.java 23 Apr 2002 16:25:39 -0000 1.107
@@ -168,9 +168,10 @@
/**
* Process a given XML document - needs cleanup.
*/
- public Element[] AdminService(MessageContext msgContext, Vector xml)
+ public Element[] AdminService(Vector xml)
throws Exception
{
+ MessageContext msgContext = MessageContext.getCurrentContext();
log.debug(JavaUtils.getMessage("enter00", "Admin:AdminService") );
Document doc = process( msgContext, (Element) xml.get(0) );
Element[] result = new Element[1];
1.16 +1 -0 xml-axis/java/test/encoding/PackageTests.java
Index: PackageTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/PackageTests.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PackageTests.java 21 Mar 2002 18:05:28 -0000 1.15
+++ PackageTests.java 23 Apr 2002 16:25:39 -0000 1.16
@@ -34,6 +34,7 @@
suite.addTestSuite(TestAttributes.class);
suite.addTestSuite(TestBeanDeser.class);
suite.addTestSuite(TestRoundTrip.class);
+ suite.addTestSuite(TestOmittedValues.class);
return suite;
}
1.1 xml-axis/java/test/encoding/TestOmittedValues.java
Index: TestOmittedValues.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 junit.framework.TestCase;
import org.apache.axis.Message;
import org.apache.axis.Constants;
import org.apache.axis.MessageContext;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.transport.local.LocalTransport;
import org.apache.axis.configuration.BasicServerConfig;
import org.apache.axis.server.AxisServer;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.rpc.namespace.QName;
/**
* A test which confirms that we can correctly call methods where null arguments
* are represented by omission from the SOAP envelope.
*
* @author Glen Daniels ([EMAIL PROTECTED])
*/
public class TestOmittedValues extends TestCase {
String header =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:me=\"urn:me\" " +
"xmlns:xsi=\"" + Constants.URI_2001_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_2001_SCHEMA_XSD + "\">\n" +
"<soap:Body>\n" +
"<method>\n";
String missingParam2 =
" <param1 xsi:type=\"xsd:string\">One</param1>\n" +
" <param3 xsi:type=\"xsd:string\">Three</param3>\n";
String footer =
"</method>\n" +
"</soap:Body>\n" +
"</soap:Envelope>\n";
public TestOmittedValues(String s) {
super(s);
}
public TestOmittedValues() {
super("service version");
}
public void testOmittedValue() throws Exception {
// Set up a server and deploy our service
BasicServerConfig config = new BasicServerConfig();
AxisServer server = new AxisServer(config);
SOAPService service = new SOAPService(new RPCProvider());
service.setOption("className", "test.encoding.TestOmittedValues");
service.setOption("allowedMethods", "*");
ServiceDesc desc = service.getServiceDescription();
// We need parameter descriptors to make sure we can match by name
// (the only way omitted==null can work).
ParameterDesc [] params = new ParameterDesc [] {
new ParameterDesc(new QName("", "param1"), ParameterDesc.IN, null),
new ParameterDesc(new QName("", "param2"), ParameterDesc.IN, null),
new ParameterDesc(new QName("", "param3"), ParameterDesc.IN, null),
};
OperationDesc oper = new OperationDesc("method", params, null);
desc.addOperationDesc(oper);
config.deployService("testOmittedValue", service);
String msg = header + missingParam2 + footer;
Message message = new Message(msg);
MessageContext context = new MessageContext(server);
context.setRequestMessage(message);
Call call = new Call(new Service());
LocalTransport transport = new LocalTransport(server);
transport.setRemoteService("testOmittedValue");
call.setTransport(transport);
SOAPEnvelope resEnv = call.invoke(message.getSOAPEnvelope());
RPCElement rpcElem = (RPCElement)resEnv.getFirstBody();
RPCParam param = (RPCParam)rpcElem.getParams().get(0);
assertEquals("OK!", param.getValue());
}
// Server-side test method for omitting values
public String method(String p1, String p2, String p3) {
if (p1.equals("One") && p2 == null && p3.equals("Three")) {
return "OK!";
}
return "Bad arguments!";
}
}