dims 2002/12/02 11:12:15
Modified: java/src/org/apache/axis/encoding
SerializationContextImpl.java
java/src/org/apache/axis/encoding/ser VectorSerializer.java
java/src/org/apache/axis/i18n resource.properties
java/src/org/apache/axis/message RPCElement.java
java/src/org/apache/axis/utils JavaUtils.java
java/test/encoding TestCircularRefs.java
java/test/functional FunctionalTests.java
java/test/utils TestJavaUtils.java
Added: java/src/org/apache/axis/utils IDKey.java
IdentityHashMap.java
java/test/functional TestIF3SOAP.java
java/test/rpc Bean.java IF1.java IF2SOAP.java
IF2SOAPProxy.java IF3SOAP.java IF3SOAPImpl.java
IF3SOAPProxy.java build.xml deploy.wsdd
undeploy.wsdd
Log:
Bug 13324 - Deserialization of circular references is broken
Bug 13949 - ArrayStoreException during method invocation
Bug 13402 - Wrong service method gets invoked
Notes:
1. 13949 and 13402 are caused by the fact that we pick up the first operation that
has the same # of parameters...Now am doing additional check to ensure that the
objects are convertable as well (to find the correct operation).
2. See test/rpc for testcase for 13949 and 13402
3. The circularity test causes StockOverFlowError on both JDK1.3 and JDK1.4, so i
added a check for recursion in VectorSerializer and throw an exception if the vectors
are recursive to prevent StackOverFlow error.
4. Tighten up the screws on isConvertable (it was allowing String[]->Calendar[])
which is wrong. added a testcase as well.
Revision Changes Path
1.81 +1 -26
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.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- SerializationContextImpl.java 25 Nov 2002 19:53:08 -0000 1.80
+++ SerializationContextImpl.java 2 Dec 2002 19:12:12 -0000 1.81
@@ -70,6 +70,7 @@
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.client.Call;
+import org.apache.axis.utils.IDKey;
import org.apache.axis.utils.Mapping;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.NSStack;
@@ -770,32 +771,6 @@
*/
private IDKey getIdentityKey(Object value) {
return new IDKey(value);
- }
- class IDKey {
- private Object value = null;
- private int id = 0;
- public IDKey(Object _value) {
- // This is the Object hashcode
- id = System.identityHashCode(_value);
- // There have been some cases (bug 11706) that return the
- // same identity hash code for different objects. So
- // the value is also added to disambiguate these cases.
- value = _value;
- }
- public int hashCode() {
- return id;
- }
- public boolean equals(Object other) {
- if (!(other instanceof IDKey)) {
- return false;
- }
- IDKey idKey = (IDKey) other;
- if (id != idKey.id) {
- return false;
- }
- // Note that identity equals is used.
- return value == idKey.value;
- }
}
/**
1.16 +26 -1
xml-axis/java/src/org/apache/axis/encoding/ser/VectorSerializer.java
Index: VectorSerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/VectorSerializer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- VectorSerializer.java 4 Nov 2002 17:01:27 -0000 1.15
+++ VectorSerializer.java 2 Dec 2002 19:12:12 -0000 1.16
@@ -66,10 +66,12 @@
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.utils.Messages;
+import org.apache.axis.utils.IdentityHashMap;
import java.io.IOException;
import java.util.Iterator;
import java.util.Vector;
+import java.util.Stack;
import org.apache.axis.components.logger.LogFactory;
import org.apache.commons.logging.Log;
@@ -110,7 +112,12 @@
value.getClass().getName()));
Vector vector = (Vector)value;
-
+
+ // Check for circular references.
+ if(isRecursive(new IdentityHashMap(), vector)){
+ throw new IOException(Messages.getMessage("badVector00"));
+ }
+
context.startElement(name, attributes);
for (Iterator i = vector.iterator(); i.hasNext(); )
{
@@ -118,6 +125,24 @@
context.serialize(Constants.QNAME_LITERAL_ITEM, null, item);
}
context.endElement();
+ }
+
+ public boolean isRecursive(IdentityHashMap map, Vector vector)
+ {
+ map.add(vector);
+ boolean recursive = false;
+ for(int i=0;i<vector.size() && !recursive;i++)
+ {
+ Object o = vector.get(i);
+ if(o instanceof Vector) {
+ if(map.containsKey(o)) {
+ return true;
+ } else {
+ recursive = isRecursive(map, (Vector)o);
+ }
+ }
+ }
+ return recursive;
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.34 +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.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- resource.properties 1 Dec 2002 00:03:42 -0000 1.33
+++ resource.properties 2 Dec 2002 19:12:12 -0000 1.34
@@ -897,6 +897,7 @@
CantGetSerializer=unable to get serializer for class {0}
noVector00={0}: {1} is not a vector
+badVector00=Circular reference in Vector
optionFactory00=name of a custom class that implements GeneratorFactory interface
(for extending Java generation functions)
optionHelper00=emits separate Helper classes for meta data
1.79 +28 -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.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- RPCElement.java 1 Nov 2002 17:39:24 -0000 1.78
+++ RPCElement.java 2 Dec 2002 19:12:13 -0000 1.79
@@ -67,6 +67,7 @@
import org.apache.axis.enum.Use;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.utils.Messages;
+import org.apache.axis.utils.JavaUtils;
import org.apache.axis.wsdl.toJava.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -227,7 +228,33 @@
context, rpcHandler);
}
-
+ // Check if the RPCParam's value match the signature of the
+ // param in the operation.
+ boolean match = true;
+ for ( int j = 0 ; j < params.size() && match ; j++ ) {
+ RPCParam rpcParam = (RPCParam)params.get(j);
+ Object value = rpcParam.getValue();
+
+ // first check the type on the paramter
+ ParameterDesc paramDesc = rpcParam.getParamDesc();
+
+ // if we found some type info try to make sure the
value type is
+ // correct. For instance, if we deserialized a
xsd:dateTime in
+ // to a Calendar and the service takes a Date, we need
to convert
+ if (paramDesc != null && paramDesc.getJavaType() !=
null) {
+
+ // Get the type in the signature (java type or its
holder)
+ Class sigType = paramDesc.getJavaType();
+ if(!JavaUtils.isConvertable(value, sigType))
+ match = false;
+ }
+ }
+ // This is not the right operation, try the next one.
+ if(!match) {
+ params = new Vector();
+ continue;
+ }
+
// Success!! This is the right one...
msgContext.setOperation(operation);
return;
1.85 +10 -2 xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
Index: JavaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- JavaUtils.java 30 Nov 2002 03:33:41 -0000 1.84
+++ JavaUtils.java 2 Dec 2002 19:12:13 -0000 1.85
@@ -481,6 +481,9 @@
} else {
src = obj.getClass();
}
+ } else {
+ if(!dest.isPrimitive())
+ return true;
}
if (dest == null)
@@ -499,8 +502,13 @@
// If it's List -> Array or vice versa, we're good.
if ((Collection.class.isAssignableFrom(src) || src.isArray()) &&
- (Collection.class.isAssignableFrom(dest) || dest.isArray()))
- return true;
+ (Collection.class.isAssignableFrom(dest) || dest.isArray()) &&
+ (src.getComponentType() == Object.class ||
+ src.getComponentType() == null ||
+ dest.getComponentType() == Object.class ||
+ dest.getComponentType() == null ||
+ isConvertable(src.getComponentType(), dest.getComponentType())))
+ return true;
// If destination is an array, and src is a component, we're good.
if (dest.isArray() &&
1.1 xml-axis/java/src/org/apache/axis/utils/IDKey.java
Index: IDKey.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 org.apache.axis.utils;
/**
* Wrap an identity key (System.identityHashCode())
*/
public class IDKey {
private Object value = null;
private int id = 0;
/**
* Constructor for IDKey
* @param _value
*/
public IDKey(Object _value) {
// This is the Object hashcode
id = System.identityHashCode(_value);
// There have been some cases (bug 11706) that return the
// same identity hash code for different objects. So
// the value is also added to disambiguate these cases.
value = _value;
}
/**
* returns hashcode
* @return
*/
public int hashCode() {
return id;
}
/**
* checks if instances are equal
* @param other
* @return
*/
public boolean equals(Object other) {
if (!(other instanceof IDKey)) {
return false;
}
IDKey idKey = (IDKey) other;
if (id != idKey.id) {
return false;
}
// Note that identity equals is used.
return value == idKey.value;
}
}
1.3 +59 -142 xml-axis/java/src/org/apache/axis/utils/IdentityHashMap.java
1.2 +8 -3 xml-axis/java/test/encoding/TestCircularRefs.java
Index: TestCircularRefs.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/TestCircularRefs.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestCircularRefs.java 1 Dec 2002 19:48:17 -0000 1.1
+++ TestCircularRefs.java 2 Dec 2002 19:12:14 -0000 1.2
@@ -5,6 +5,7 @@
import java.util.Vector;
import org.apache.axis.client.Call;
+import org.apache.axis.AxisFault;
public class TestCircularRefs extends GenericLocalTest {
public TestCircularRefs() {
@@ -16,9 +17,13 @@
}
public void testCircularVectors() throws Exception {
- Call call = getCall();
- Object result = call.invoke("getCircle", null);
-
+ try {
+ Call call = getCall();
+ Object result = call.invoke("getCircle", null);
+ } catch (AxisFault af){
+ return;
+ }
+ fail("Expected a fault");
// This just tests that we don't get exceptions during deserialization
// for now. We're still getting nulls for some reason, and once that's
// fixed we should uncomment this next line
1.23 +3 -0 xml-axis/java/test/functional/FunctionalTests.java
Index: FunctionalTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- FunctionalTests.java 20 Jun 2002 16:48:20 -0000 1.22
+++ FunctionalTests.java 2 Dec 2002 19:12:14 -0000 1.23
@@ -59,6 +59,9 @@
// Message service test.
suite.addTestSuite(TestMessageSample.class);
+
+ // test.rpc test
+ suite.addTestSuite(TestIF3SOAP.class);
// Attachments service test.
try{
1.1 xml-axis/java/test/functional/TestIF3SOAP.java
Index: TestIF3SOAP.java
===================================================================
package test.functional;
import junit.framework.TestCase;
import org.apache.axis.client.AdminClient;
import test.rpc.IF1;
import test.rpc.IF2SOAP;
import test.rpc.IF3SOAP;
import test.rpc.IF3SOAPProxy;
import java.util.Calendar;
import java.util.GregorianCalendar;
public final class TestIF3SOAP extends TestCase {
private static final String URL = "http://localhost:8080/axis/services/IF3SOAP";
private static final String Service = "IF3SOAP";
private IF3SOAPProxy m_soap;
public static void main(String args[]) {
junit.textui.TestRunner.run(TestIF3SOAP.class);
}
public TestIF3SOAP(String name) {
super(name);
}
protected void setUp() {
if (m_soap == null)
m_soap = new IF3SOAPProxy(Service, URL);
} // setUp
protected void tearDown() {
} // tearDown
public void testGetBeanById() {
try {
IF2SOAP soap = m_soap;
IF1 bean = soap.getBeanById("42042042042");
assertNotNull("bean is null", bean);
System.out.println("beanById:");
System.out.println("id: " + bean.getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetAllBeans() {
try {
IF2SOAP soap = m_soap;
IF1[] beans = soap.getAllBeans();
assertNotNull("beans is null", beans);
System.out.println("allBeans:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetAllBeansFiltered() {
try {
IF2SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
IF1[] beans = soap.getAllBeans(filter);
assertNotNull("beans is null", beans);
System.out.println("allBeansFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetAllCategories() {
try {
IF2SOAP soap = m_soap;
String[] categories = soap.getAllCategories();
assertNotNull("categories is null", categories);
System.out.println("allCategories:");
for (int i = 0; i < categories.length; i++)
System.out.println("cat[" + i + "]: " + categories[i]);
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByCategory() {
try {
IF2SOAP soap = m_soap;
IF1[] beans = soap.getBeansByCategory("Test");
assertNotNull("beans is null", beans);
System.out.println("beansByCategory:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByCategoryFiltered() {
try {
IF2SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
IF1[] beans = soap.getBeansByCategory("Test", filter);
assertNotNull("beans is null", beans);
System.out.println("beansByCategoryFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByDate() {
try {
IF2SOAP soap = m_soap;
Calendar[] dates = new Calendar[1];
dates[0] = new GregorianCalendar();
IF1[] beans = soap.getBeansByDate(dates);
assertNotNull("beans is null", beans);
System.out.println("beansByDate:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByDateFiltered() {
try {
IF2SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
Calendar[] dates = new Calendar[1];
dates[0] = new GregorianCalendar();
IF1[] beans = soap.getBeansByDate(dates, filter);
assertNotNull("beans is null", beans);
System.out.println("beansByDateFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByExpression() {
try {
IF2SOAP soap = m_soap;
IF1[] beans = soap.getBeansByExpression(IF2SOAP.KEYWORD_EXP, "keyword");
assertNotNull("beans is null", beans);
System.out.println("beansByExpression:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansByExpressionFiltered() {
try {
IF2SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
IF1[] beans = soap.getBeansByExpression(IF2SOAP.KEYWORD_EXP, "keyword",
filter);
assertNotNull("beans is null", beans);
System.out.println("beansByExpressionFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetXMLForBean() {
try {
IF2SOAP soap = m_soap;
IF1 bean = soap.getBeanById("42042042042");
String xml = soap.getXMLForBean(bean);
assertNotNull("xml is null", xml);
System.out.println("xmlForBean:");
System.out.println("xml: " + xml);
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByCategory() {
try {
IF3SOAP soap = m_soap;
IF1[] beans = soap.getBeansByCategory("if", "Test");
assertNotNull("beans is null", beans);
System.out.println("beansForIFByCategory:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByCategoryFiltered() {
try {
IF3SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
IF1[] beans = soap.getBeansByCategory("if", "Test", filter);
assertNotNull("beans is null", beans);
System.out.println("beansForIFByCategoryFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByDate() {
try {
IF3SOAP soap = m_soap;
Calendar[] dates = new Calendar[1];
dates[0] = new GregorianCalendar();
IF1[] beans = soap.getBeansByDate("if", dates);
assertNotNull("beans is null", beans);
System.out.println("beansForIFByDate:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByDateFiltered() {
try {
IF3SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
Calendar[] dates = new Calendar[1];
dates[0] = new GregorianCalendar();
IF1[] beans = soap.getBeansByDate("if", dates, filter);
assertNotNull("beans is null", beans);
System.out.println("beansForIFByDateFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByExpression() {
try {
IF3SOAP soap = m_soap;
IF1[] beans = soap.getBeansByExpression("if", IF2SOAP.KEYWORD_EXP,
"keyword");
assertNotNull("beans is null", beans);
System.out.println("beansForIFByExpression:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
public void testGetBeansForIFByExpressionFiltered() {
try {
IF3SOAP soap = m_soap;
String[] filter = new String[1];
filter[0] = "11011011011";
IF1[] beans = soap.getBeansByExpression("if", IF2SOAP.KEYWORD_EXP,
"keyword", filter);
assertNotNull("beans is null", beans);
System.out.println("beansForIFByExpressionFiltered:");
for (int i = 0; i < beans.length; i++)
System.out.println("id[" + i + "]: " + beans[i].getId());
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
}
1.1 xml-axis/java/test/rpc/Bean.java
Index: Bean.java
===================================================================
package test.rpc;
import java.util.Calendar;
public class Bean implements IF1
{
protected String id;
protected String title;
protected String category;
protected Calendar date;
public Bean()
{
}
public String getId()
{
return id;
}
public void setId(String aId)
{
id = aId;
}
public String getTitle()
{
return title;
}
public void setTitle(String aTitle)
{
title = aTitle;
}
public String getCategory()
{
return category;
}
public void setCategory(String aCategory)
{
category = aCategory;
}
public Calendar getDate()
{
return date;
}
public void setDate(Calendar aDate)
{
date = aDate;
}
}
1.1 xml-axis/java/test/rpc/IF1.java
Index: IF1.java
===================================================================
package test.rpc;
import java.util.Calendar;
public interface IF1
{
public String getId();
public String getTitle();
public String getCategory();
public Calendar getDate();
}
1.1 xml-axis/java/test/rpc/IF2SOAP.java
Index: IF2SOAP.java
===================================================================
package test.rpc;
import java.util.Calendar;
public interface IF2SOAP
{
public static final int KEYWORD_EXP = 0;
public static final int CONTENT_EXP = 1;
public IF1 getBeanById(String id)
throws Exception;
public IF1[] getAllBeans()
throws Exception;
public IF1[] getAllBeans(String[] filter)
throws Exception;
public String[] getAllCategories()
throws Exception;
public IF1[] getBeansByCategory(String category)
throws Exception;
public IF1[] getBeansByCategory(String category, String[] filter)
throws Exception;
public IF1[] getBeansByDate(Calendar[] dates)
throws Exception;
public IF1[] getBeansByDate(Calendar[] dates, String[] filter)
throws Exception;
public IF1[] getBeansByExpression(int expType, String expression)
throws Exception;
public IF1[] getBeansByExpression(int expType, String expression, String[]
filter)
throws Exception;
public String getXMLForBean(IF1 bean)
throws Exception;
}
1.1 xml-axis/java/test/rpc/IF2SOAPProxy.java
Index: IF2SOAPProxy.java
===================================================================
package test.rpc;
import java.util.Calendar;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
public final class IF2SOAPProxy implements IF2SOAP
{
private String m_service;
private String m_url;
private QName m_beanQName;
private QName m_beanArrayQName;
private QName m_stringArrayQName;
private QName m_calendarArrayQName;
public IF2SOAPProxy(String service, String url)
{
m_service = service;
m_url = url;
m_beanQName = new QName("urn:" + m_service, "Bean");
m_beanArrayQName = new QName("urn:" + m_service, "Bean[]");
m_stringArrayQName = new QName("urn:" + m_service, "String[]");
m_calendarArrayQName = new QName("urn:" + m_service, "Calendar[]");
}
public IF1 getBeanById(String id)
throws Exception
{
IF1 bean = null;
if (id == null)
throw new Exception("invalid id");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeanById"));
call.addParameter("id", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.setReturnType(m_beanQName);
bean = (IF1) call.invoke(new Object[] { id });
return bean;
}
public IF1[] getAllBeans()
throws Exception
{
return getAllBeans(null);
}
public IF1[] getAllBeans(String[] filter)
throws Exception
{
IF1[] beans = null;
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getAllBeans"));
call.setReturnType(m_beanArrayQName);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[0]);
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { filter });
}
return beans;
}
public String[] getAllCategories()
throws Exception
{
String[] categories = null;
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getAllCategories"));
call.setReturnType(m_stringArrayQName);
categories = (String[]) call.invoke(new Object[0]);
return categories;
}
public IF1[] getBeansByCategory(String category)
throws Exception
{
return getBeansByCategory(category, null);
}
public IF1[] getBeansByCategory(String category, String[] filter)
throws Exception
{
IF1[] beans = null;
if (category == null)
throw new Exception("invalid category");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByCategory"));
call.setReturnType(m_beanArrayQName);
call.addParameter("category", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { category });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { category, filter });
}
return beans;
}
public IF1[] getBeansByDate(Calendar[] dates)
throws Exception
{
return getBeansByDate(dates, null);
}
public IF1[] getBeansByDate(Calendar[] dates, String[] filter)
throws Exception
{
IF1[] beans = null;
if (dates == null)
throw new Exception("invalid dates");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByDate"));
call.setReturnType(m_beanArrayQName);
call.addParameter("dates", m_calendarArrayQName, ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { dates });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { dates, filter });
}
return beans;
}
public IF1[] getBeansByExpression(int expType, String expression)
throws Exception
{
return getBeansByExpression(expType, expression, null);
}
public IF1[] getBeansByExpression(int expType, String expression, String[]
filter)
throws Exception
{
IF1[] beans = null;
if (expression == null)
throw new Exception("invalid expression");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByExpression"));
call.setReturnType(m_beanArrayQName);
call.addParameter("expType", org.apache.axis.Constants.XSD_INT,
ParameterMode.IN);
call.addParameter("expression", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { new Integer(expType),
expression });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { new Integer(expType),
expression, filter });
}
return beans;
}
public String getXMLForBean(IF1 bean)
throws Exception
{
String xml = null;
if (bean == null)
throw new Exception("invalid bean");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getXMLForBean"));
call.addParameter("bean", m_beanQName, ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
xml = (String) call.invoke(new Object[] { bean });
return xml;
}
private Call getCall()
throws Exception
{
Call call = null;
Service service = new Service();
call = (Call) service.createCall();
call.registerTypeMapping(Bean.class, m_beanQName,
new BeanSerializerFactory(Bean.class, m_beanQName),
new BeanDeserializerFactory(Bean.class, m_beanQName));
return call;
}
}
1.1 xml-axis/java/test/rpc/IF3SOAP.java
Index: IF3SOAP.java
===================================================================
package test.rpc;
import java.util.Calendar;
public interface IF3SOAP extends IF2SOAP
{
public IF1[] getBeansByCategory(String ifId, String category)
throws Exception;
public IF1[] getBeansByCategory(String ifId, String category, String[] filter)
throws Exception;
public IF1[] getBeansByDate(String ifId, Calendar[] dates)
throws Exception;
public IF1[] getBeansByDate(String ifId, Calendar[] dates, String[] filter)
throws Exception;
public IF1[] getBeansByExpression(String ifId, int expType, String expression)
throws Exception;
public IF1[] getBeansByExpression(String ifId, int expType, String expression,
String[] filter)
throws Exception;
}
1.1 xml-axis/java/test/rpc/IF3SOAPImpl.java
Index: IF3SOAPImpl.java
===================================================================
package test.rpc;
import java.util.Calendar;
import java.util.GregorianCalendar;
//import org.jdom.Document;
//import org.jdom.output.XMLOutputter;
public final class IF3SOAPImpl implements IF3SOAP
{
private Bean[] m_beans;
private String[] m_categories;
public IF3SOAPImpl()
{
Bean bean1 = new Bean();
bean1.setId("42042042042");
bean1.setTitle("Test Bean");
bean1.setCategory("Test");
Calendar date = new GregorianCalendar();
bean1.setDate(date);
Bean bean2 = new Bean();
bean2.setId("11011011011");
bean2.setTitle("Test Bean 2");
bean2.setCategory("Test 2");
bean2.setDate(date);
m_beans = new Bean[2];
m_beans[0] = bean1;
m_beans[1] = bean2;
m_categories = new String[2];
m_categories[0] = "Test";
m_categories[1] = "Std";
}
public IF1 getBeanById(String id)
throws Exception
{
return m_beans[0];
}
public IF1[] getAllBeans()
throws Exception
{
return m_beans;
}
public IF1[] getAllBeans(String[] filter)
throws Exception
{
return m_beans;
}
public String[] getAllCategories()
throws Exception
{
return m_categories;
}
public IF1[] getBeansByCategory(String category)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByCategory(String category, String[] filter)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByDate(Calendar[] dates)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByDate(Calendar[] dates, String[] filter)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByExpression(int expType, String expression)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByExpression(int expType, String expression, String[]
filter)
throws Exception
{
return m_beans;
}
public String getXMLForBean(IF1 bean)
throws Exception
{
return "<bean>\n</bean>";
}
public IF1[] getBeansByCategory(String ifId, String category)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByCategory(String ifId, String category, String[] filter)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByDate(String ifId, Calendar[] dates)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByDate(String ifId, Calendar[] dates, String[] filter)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByExpression(String ifId, int expType, String expression)
throws Exception
{
return m_beans;
}
public IF1[] getBeansByExpression(String ifId, int expType, String expression,
String[] filter)
throws Exception
{
return m_beans;
}
}
1.1 xml-axis/java/test/rpc/IF3SOAPProxy.java
Index: IF3SOAPProxy.java
===================================================================
package test.rpc;
import java.util.Calendar;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
public final class IF3SOAPProxy implements IF3SOAP
{
private String m_service;
private String m_url;
private QName m_beanQName;
private QName m_beanArrayQName;
private QName m_stringArrayQName;
private QName m_calendarArrayQName;
public IF3SOAPProxy(String service, String url)
{
m_service = service;
m_url = url;
m_beanQName = new QName("urn:" + m_service, "Bean");
m_beanArrayQName = new QName("urn:" + m_service, "Bean[]");
m_stringArrayQName = new QName("urn:" + m_service, "String[]");
m_calendarArrayQName = new QName("urn:" + m_service, "Calendar[]");
}
public IF1 getBeanById(String id)
throws Exception
{
IF1 bean = null;
if (id == null)
throw new Exception("invalid id");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeanById"));
call.addParameter("id", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.setReturnType(m_beanQName);
bean = (IF1) call.invoke(new Object[] { id });
return bean;
}
public IF1[] getAllBeans()
throws Exception
{
return getAllBeans(null);
}
public IF1[] getAllBeans(String[] filter)
throws Exception
{
IF1[] beans = null;
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getAllBeans"));
call.setReturnType(m_beanArrayQName);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[0]);
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { filter });
}
return beans;
}
public String[] getAllCategories()
throws Exception
{
String[] categories = null;
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getAllCategories"));
call.setReturnType(m_stringArrayQName);
categories = (String[]) call.invoke(new Object[0]);
return categories;
}
public IF1[] getBeansByCategory(String category)
throws Exception
{
return getBeansByCategory(category, (String[]) null);
}
public IF1[] getBeansByCategory(String category, String[] filter)
throws Exception
{
IF1[] beans = null;
if (category == null)
throw new Exception("invalid category");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByCategory"));
call.setReturnType(m_beanArrayQName);
call.addParameter("category", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { category });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { category, filter });
}
return beans;
}
public IF1[] getBeansByDate(Calendar[] dates)
throws Exception
{
return getBeansByDate(dates, null);
}
public IF1[] getBeansByDate(Calendar[] dates, String[] filter)
throws Exception
{
IF1[] beans = null;
if (dates == null)
throw new Exception("invalid dates");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByDate"));
call.setReturnType(m_beanArrayQName);
call.addParameter("dates", m_calendarArrayQName, ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { dates });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { dates, filter });
}
return beans;
}
public IF1[] getBeansByExpression(int expType, String expression)
throws Exception
{
return getBeansByExpression(expType, expression, null);
}
public IF1[] getBeansByExpression(int expType, String expression, String[]
filter)
throws Exception
{
IF1[] beans = null;
if (expression == null)
throw new Exception("invalid expression");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByExpression"));
call.setReturnType(m_beanArrayQName);
call.addParameter("expType", org.apache.axis.Constants.XSD_INT,
ParameterMode.IN);
call.addParameter("expression", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { new Integer(expType),
expression });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { new Integer(expType),
expression, filter });
}
return beans;
}
public String getXMLForBean(IF1 bean)
throws Exception
{
String xml = null;
if (bean == null)
throw new Exception("invalid bean");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getXMLForBean"));
call.addParameter("bean", m_beanQName, ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
xml = (String) call.invoke(new Object[] { bean });
return xml;
}
public IF1[] getBeansByCategory(String ifId, String category)
throws Exception
{
return getBeansByCategory(ifId, category, null);
}
public IF1[] getBeansByCategory(String ifId, String category, String[] filter)
throws Exception
{
IF1[] beans = null;
if (ifId == null)
throw new Exception("invalid ifId");
if (category == null)
throw new Exception("invalid category");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByCategory"));
call.setReturnType(m_beanArrayQName);
call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("category", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { ifId, category });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { ifId, category, filter });
}
return beans;
}
public IF1[] getBeansByDate(String ifId, Calendar[] dates)
throws Exception
{
return getBeansByDate(ifId, dates, null);
}
public IF1[] getBeansByDate(String ifId, Calendar[] dates, String[] filter)
throws Exception
{
IF1[] beans = null;
if (ifId == null)
throw new Exception("invalid ifId");
if (dates == null)
throw new Exception("invalid dates");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByDate"));
call.setReturnType(m_beanArrayQName);
call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("dates", m_calendarArrayQName, ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { ifId, dates });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { ifId, dates, filter });
}
return beans;
}
public IF1[] getBeansByExpression(String ifId, int expType, String expression)
throws Exception
{
return getBeansByExpression(ifId, expType, expression, null);
}
public IF1[] getBeansByExpression(String ifId, int expType, String expression,
String[] filter)
throws Exception
{
IF1[] beans = null;
if (ifId == null)
throw new Exception("invalid ifId");
if (expression == null)
throw new Exception("invalid expression");
Call call = getCall();
call.setTargetEndpointAddress(m_url);
call.setOperationName(new QName(m_service, "getBeansByExpression"));
call.setReturnType(m_beanArrayQName);
call.addParameter("ifId", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("expType", org.apache.axis.Constants.XSD_INT,
ParameterMode.IN);
call.addParameter("expression", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
if (filter == null)
beans = (IF1[]) call.invoke(new Object[] { ifId, new
Integer(expType), expression });
else
{
call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
beans = (IF1[]) call.invoke(new Object[] { ifId, new
Integer(expType), expression, filter });
}
return beans;
}
private Call getCall()
throws Exception
{
Call call = null;
Service service = new Service();
call = (Call) service.createCall();
call.registerTypeMapping(Bean.class, m_beanQName,
new BeanSerializerFactory(Bean.class, m_beanQName),
new BeanDeserializerFactory(Bean.class, m_beanQName));
return call;
}
}
1.1 xml-axis/java/test/rpc/build.xml
Index: build.xml
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "file:../../xmls/properties.xml">
<!ENTITY paths SYSTEM "file:../../xmls/path_refs.xml">
<!ENTITY taskdefs SYSTEM "file:../../xmls/taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM
"file:../../xmls/taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "file:../../xmls/targets.xml">
]>
<!-- ===================================================================
<description>
Test/Sample Component file for Axis
Notes:
This is a build file for use with the Jakarta Ant build tool.
Prerequisites:
jakarta-ant from http://jakarta.apache.org
Build Instructions:
To compile
ant compile
To execute
ant run
Author:
Matt Seibert [EMAIL PROTECTED]
Copyright:
Copyright (c) 2002-2003 Apache Software Foundation.
</description>
==================================================================== -->
<project default="compile">
<property name="axis.home" location="../.." />
<property name="componentName" value="test/rpc" />
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<target name="clean">
<echo message="Removing ${build.dir}/classes/${componentName} and
${build.dir}/work/${componentName}" />
<delete dir="${build.dir}/classes/${componentName}"/>
<delete dir="${build.dir}/work/${componentName}"/>
</target>
<target name="copy" depends="setenv"/>
<target name="compile" depends="copy">
<echo message="Compiling test.rpc"/>
<copy todir="${build.dir}/work/test/rpc" overwrite="yes">
<fileset dir="${axis.home}/test/rpc">
<include name="*.wsdd"/>
</fileset>
</copy>
<javac srcdir="${axis.home}" destdir="${build.dest}" debug="${debug}"
fork="${javac.fork}">
<classpath>
<path refid="classpath"/>
</classpath>
<include name="test/rpc/*.java"/>
</javac>
</target>
<target name="run" >
<antcall target="execute-Component" />
</target>
</project>
1.1 xml-axis/java/test/rpc/deploy.wsdd
Index: deploy.wsdd
===================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="IF3SOAP" provider="Handler">
<parameter name="allowedMethods"
value="getBeanById,getAllBeans,getAllCategories,getBeansByCategory,getBeansByDate,getBeansByExpression,getXMLForBean"/>
<parameter name="className" value="test.rpc.IF3SOAPImpl"/>
<parameter name="handlerClass"
value="org.apache.axis.providers.java.RPCProvider"/>
<beanMapping qname="myNS:Bean" xmlns:myNS="urn:IF3SOAP"
languageSpecificType="java:test.rpc.Bean"/>
</service>
</deployment>
1.1 xml-axis/java/test/rpc/undeploy.wsdd
Index: undeploy.wsdd
===================================================================
<undeployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="IF3SOAP" provider="Handler">
</service>
</undeployment>
1.15 +11 -0 xml-axis/java/test/utils/TestJavaUtils.java
Index: TestJavaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/utils/TestJavaUtils.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestJavaUtils.java 22 Oct 2002 16:02:16 -0000 1.14
+++ TestJavaUtils.java 2 Dec 2002 19:12:15 -0000 1.15
@@ -15,6 +15,7 @@
import java.util.Set;
import java.util.HashSet;
import java.util.Vector;
+import java.util.Calendar;
import java.lang.reflect.Array;
public class TestJavaUtils extends TestCase
@@ -151,6 +152,16 @@
assertTrue(JavaUtils.isConvertable(clazz,Byte.class));
assertTrue(JavaUtils.isConvertable(clazz,Object.class));
}
+
+ /**
+ * Make sure we can't say convert from string[] to Calendar[]
+ */
+ public void testIsConvert2()
+ {
+ String[] strings = new String[]{"hello"};
+ Calendar[] calendars = new Calendar[1];
+ assertTrue(!JavaUtils.isConvertable(strings, calendars.getClass()));
+ }
public static void main(String args[]){
TestJavaUtils tester = new TestJavaUtils("TestJavaUtils");