butek 02/03/31 15:09:34
Modified: java/samples/echo EchoServiceBindingStub.java
TestClient.java
java/src/javax/xml/rpc/holders Holder.java
java/src/org/apache/axis/encoding
DefaultTypeMappingImpl.java
SerializationContextImpl.java
java/src/org/apache/axis/encoding/ser DateDeserializer.java
DateSerializer.java
java/src/org/apache/axis/wsdl/toJava JavaImplWriter.java
JavaTestCaseWriter.java Utils.java
java/test/encoding TestDeser2001.java
java/test/wsdl/roundtrip BondInvestment.java
CallOptions.java RoundtripPortType.java
RoundtripTestServiceTestCase.java
RoundtripTestSoapBindingImpl.java
java/test/wsdl/types ComprehensiveTypes.wsdl
VerifyTestCase.java
Added: java/src/org/apache/axis/encoding/ser
CalendarDeserializer.java
CalendarDeserializerFactory.java
CalendarSerializer.java
CalendarSerializerFactory.java
Log:
Changed mapping of xsd:dateTime from java.util.Date to java.util.Calendar
according to JAX-RPC. JAX-RPC doesn't have the mapping of xsd:Date
but I think it's reasonable to map it to java.util.Date. This required the
following changes:
1. Changed Date(De)Serializer & Factories
2. Added Calendar(De)Serializer & Factories
3. Changed some tests/samples to use Calendar for dateTime
4. Added xsd:date to some tests (comprehensive types & roundtrip)
Revision Changes Path
1.7 +2 -2 xml-axis/java/samples/echo/EchoServiceBindingStub.java
Index: EchoServiceBindingStub.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/EchoServiceBindingStub.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EchoServiceBindingStub.java 27 Mar 2002 17:53:05 -0000 1.6
+++ EchoServiceBindingStub.java 31 Mar 2002 23:09:33 -0000 1.7
@@ -436,8 +436,8 @@
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call call = getCall();
- call.addParameter("inputDate", new
javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema", "dateTime"),
javax.xml.rpc.ParameterMode.IN);
- call.setReturnType(new
javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema", "dateTime"));
+ call.addParameter("inputDate", new
javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema", "date"),
javax.xml.rpc.ParameterMode.IN);
+ call.setReturnType(new
javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema", "date"));
call.setUseSOAPAction(true);
String methodName = (addMethodToAction) ? "echoDate" : "";
call.setSOAPActionURI(soapAction+methodName);
1.59 +11 -6 xml-axis/java/samples/echo/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/TestClient.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- TestClient.java 28 Mar 2002 22:40:47 -0000 1.58
+++ TestClient.java 31 Mar 2002 23:09:33 -0000 1.59
@@ -62,12 +62,15 @@
import java.lang.reflect.Array;
import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TimeZone;
import java.io.StringWriter;
import java.io.PrintWriter;
@@ -350,15 +353,17 @@
}
}
}
-
+ Date inputDate = null;
{
- Date input = new Date();
try {
- output = binding.echoDate(input);
- verify("echoDate", input, output);
+ SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd");
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+ inputDate = zulu.parse(zulu.format(new Date()));
+ output = binding.echoDate(inputDate);
+ verify("echoDate", inputDate, output);
} catch (Exception e) {
if (!testMode) {
- verify("echoDate", input, e);
+ verify("echoDate", inputDate, e);
} else {
throw e;
}
@@ -395,7 +400,7 @@
HashMap map = new HashMap();
map.put(new Integer(5), "String Value");
- map.put("String Key", new Date());
+ map.put("String Key", inputDate);
{
HashMap input = map;
try {
1.2 +2 -3 xml-axis/java/src/javax/xml/rpc/holders/Holder.java
Index: Holder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/javax/xml/rpc/holders/Holder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Holder.java 1 Feb 2002 04:42:26 -0000 1.1
+++ Holder.java 31 Mar 2002 23:09:33 -0000 1.2
@@ -59,7 +59,6 @@
*
* @version 0.7
*/
-public interface Holder extends java.io.Serializable {
-};
-
+public interface Holder {
+}
1.15 +5 -3
xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
Index: DefaultTypeMappingImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultTypeMappingImpl.java 27 Mar 2002 17:53:06 -0000 1.14
+++ DefaultTypeMappingImpl.java 31 Mar 2002 23:09:33 -0000 1.15
@@ -67,6 +67,8 @@
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.encoding.ser.CalendarSerializerFactory;
+import org.apache.axis.encoding.ser.CalendarDeserializerFactory;
import org.apache.axis.encoding.ser.DateSerializerFactory;
import org.apache.axis.encoding.ser.DateDeserializerFactory;
import org.apache.axis.encoding.ser.Base64SerializerFactory;
@@ -271,10 +273,10 @@
new DateDeserializerFactory(java.util.Date.class,
Constants.XSD_DATE1),
true);
- myRegister(Constants.XSD_DATE, java.util.Date.class,
- new DateSerializerFactory(java.util.Date.class,
+ myRegister(Constants.XSD_DATE, java.util.Calendar.class,
+ new CalendarSerializerFactory(java.util.Calendar.class,
Constants.XSD_DATE),
- new DateDeserializerFactory(java.util.Date.class,
+ new CalendarDeserializerFactory(java.util.Calendar.class,
Constants.XSD_DATE),
true);
1.14 +2 -0
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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SerializationContextImpl.java 27 Mar 2002 19:27:47 -0000 1.13
+++ SerializationContextImpl.java 31 Mar 2002 23:09:33 -0000 1.14
@@ -85,6 +85,7 @@
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -400,6 +401,7 @@
if (javaType.isPrimitive()) return true;
if (String.class.isAssignableFrom(javaType)) return true;
+ if (Calendar.class.isAssignableFrom(javaType)) return true;
if (Date.class.isAssignableFrom(javaType)) return true;
if (Hex.class.isAssignableFrom(javaType)) return true;
if (Element.class.isAssignableFrom(javaType)) return true;
1.2 +7 -85
xml-axis/java/src/org/apache/axis/encoding/ser/DateDeserializer.java
Index: DateDeserializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/DateDeserializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DateDeserializer.java 26 Jan 2002 02:40:34 -0000 1.1
+++ DateDeserializer.java 31 Mar 2002 23:09:33 -0000 1.2
@@ -55,27 +55,10 @@
package org.apache.axis.encoding.ser;
-import java.beans.IntrospectionException;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.axis.InternalException;
-import org.apache.axis.message.SOAPHandler;
import org.apache.axis.utils.JavaUtils;
import javax.xml.rpc.namespace.QName;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
-import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.DeserializationContext;
-import org.apache.axis.encoding.DeserializerImpl;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@@ -91,10 +74,10 @@
public class DateDeserializer extends SimpleDeserializer {
private static SimpleDateFormat zulu =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ new SimpleDateFormat("yyyy-MM-dd");
// 0123456789 0 123456789
- private static Calendar calendar = new GregorianCalendar();
+ private static Calendar calendar = Calendar.getInstance();
static {
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -126,85 +109,24 @@
bc = true;
}
- if (source.length() < 19)
+ if (source.length() < 10)
throw new NumberFormatException(
- JavaUtils.getMessage("badDateTime00"));
+ JavaUtils.getMessage("badDate00"));
- if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
- source.charAt(10) != 'T')
+ if (source.charAt(4) != '-' || source.charAt(7) != '-')
throw new NumberFormatException(
JavaUtils.getMessage("badDate00"));
- if (source.charAt(13) != ':' || source.charAt(16) != ':')
- throw new NumberFormatException(
- JavaUtils.getMessage("badTime00"));
}
// convert what we have validated so far
try {
result = zulu.parse(source == null ? null :
- (source.substring(0,19)+".000Z") );
+ (source.substring(0,10)) );
} catch (Exception e) {
throw new NumberFormatException(e.toString());
}
-
- int pos = 19;
-
- // parse optional milliseconds
- if ( source != null ) {
- if (pos < source.length() && source.charAt(pos)=='.') {
- int milliseconds = 0;
- int start = ++pos;
- while (pos<source.length() &&
- Character.isDigit(source.charAt(pos)))
- pos++;
-
- String decimal=source.substring(start,pos);
- if (decimal.length()==3) {
- milliseconds=Integer.parseInt(decimal);
- } else if (decimal.length() < 3) {
- milliseconds=Integer.parseInt((decimal+"000")
- .substring(0,3));
- } else {
- milliseconds=Integer.parseInt(decimal.substring(0,3));
- if (decimal.charAt(3)>='5') ++milliseconds;
- }
-
- // add milliseconds to the current result
- result.setTime(result.getTime()+milliseconds);
- }
-
- // parse optional timezone
- if (pos+5 < source.length() &&
- (source.charAt(pos)=='+' || (source.charAt(pos)=='-')))
- {
- if (!Character.isDigit(source.charAt(pos+1)) ||
- !Character.isDigit(source.charAt(pos+2)) ||
- source.charAt(pos+3) != ':' ||
- !Character.isDigit(source.charAt(pos+4)) ||
- !Character.isDigit(source.charAt(pos+5)))
- throw new NumberFormatException(
-
JavaUtils.getMessage("badTimezone00"));
-
- int hours = (source.charAt(pos+1)-'0')*10
- +source.charAt(pos+2)-'0';
- int mins = (source.charAt(pos+4)-'0')*10
- +source.charAt(pos+5)-'0';
- int milliseconds = (hours*60+mins)*60*1000;
-
- // subtract milliseconds from current result to obtain GMT
- if (source.charAt(pos)=='+') milliseconds=-milliseconds;
- result.setTime(result.getTime()+milliseconds);
- pos+=6;
- }
-
- if (pos < source.length() && source.charAt(pos)=='Z') pos++;
-
- if (pos < source.length())
- throw new NumberFormatException(
- JavaUtils.getMessage("badChars00"));
- }
-
+
// support dates before the Christian era
if (bc) {
synchronized (calendar) {
1.3 +2 -11
xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java
Index: DateSerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DateSerializer.java 2 Feb 2002 18:06:18 -0000 1.2
+++ DateSerializer.java 31 Mar 2002 23:09:33 -0000 1.3
@@ -56,7 +56,6 @@
package org.apache.axis.encoding.ser;
import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
@@ -64,14 +63,7 @@
import org.apache.axis.Constants;
import org.apache.axis.wsdl.fromJava.Types;
import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.DeserializationContext;
-import org.apache.axis.encoding.DeserializerImpl;
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -89,10 +81,9 @@
public class DateSerializer implements Serializer {
private static SimpleDateFormat zulu =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- // 0123456789 0 123456789
+ new SimpleDateFormat("yyyy-MM-dd");
- private static Calendar calendar = new GregorianCalendar();
+ private static Calendar calendar = Calendar.getInstance();
static {
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
1.1
xml-axis/java/src/org/apache/axis/encoding/ser/CalendarDeserializer.java
Index: CalendarDeserializer.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.encoding.ser;
import org.apache.axis.utils.JavaUtils;
import javax.xml.rpc.namespace.QName;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
/**
* The CalendarSerializer deserializes a dateTime.
* Much of the work is done in the base class.
*
* @author Sam Ruby ([EMAIL PROTECTED])
* Modified for JAX-RPC @author Rich Scheuerle ([EMAIL PROTECTED])
*/
public class CalendarDeserializer extends SimpleDeserializer {
private static SimpleDateFormat zulu =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
// 0123456789 0 123456789
static {
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
}
/**
* The Deserializer is constructed with the xmlType and
* javaType
*/
public CalendarDeserializer(Class javaType, QName xmlType) {
super(javaType, xmlType);
}
/**
* The simple deserializer provides most of the stuff.
* We just need to override makeValue().
*/
public Object makeValue(String source) {
Calendar calendar = Calendar.getInstance();
Date date;
boolean bc = false;
// validate fixed portion of format
if ( source != null ) {
if (source.charAt(0) == '+')
source = source.substring(1);
if (source.charAt(0) == '-') {
source = source.substring(1);
bc = true;
}
if (source.length() < 19)
throw new NumberFormatException(
JavaUtils.getMessage("badDateTime00"));
if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
source.charAt(10) != 'T')
throw new NumberFormatException(
JavaUtils.getMessage("badDate00"));
if (source.charAt(13) != ':' || source.charAt(16) != ':')
throw new NumberFormatException(
JavaUtils.getMessage("badTime00"));
}
// convert what we have validated so far
try {
date = zulu.parse(source == null ? null :
(source.substring(0,19)+".000Z") );
} catch (Exception e) {
throw new NumberFormatException(e.toString());
}
int pos = 19;
// parse optional milliseconds
if ( source != null ) {
if (pos < source.length() && source.charAt(pos)=='.') {
int milliseconds = 0;
int start = ++pos;
while (pos<source.length() &&
Character.isDigit(source.charAt(pos)))
pos++;
String decimal=source.substring(start,pos);
if (decimal.length()==3) {
milliseconds=Integer.parseInt(decimal);
} else if (decimal.length() < 3) {
milliseconds=Integer.parseInt((decimal+"000")
.substring(0,3));
} else {
milliseconds=Integer.parseInt(decimal.substring(0,3));
if (decimal.charAt(3)>='5') ++milliseconds;
}
// add milliseconds to the current date
date.setTime(date.getTime()+milliseconds);
}
// parse optional timezone
if (pos+5 < source.length() &&
(source.charAt(pos)=='+' || (source.charAt(pos)=='-')))
{
if (!Character.isDigit(source.charAt(pos+1)) ||
!Character.isDigit(source.charAt(pos+2)) ||
source.charAt(pos+3) != ':' ||
!Character.isDigit(source.charAt(pos+4)) ||
!Character.isDigit(source.charAt(pos+5)))
throw new NumberFormatException(
JavaUtils.getMessage("badTimezone00"));
int hours = (source.charAt(pos+1)-'0')*10
+source.charAt(pos+2)-'0';
int mins = (source.charAt(pos+4)-'0')*10
+source.charAt(pos+5)-'0';
int milliseconds = (hours*60+mins)*60*1000;
// subtract milliseconds from current date to obtain GMT
if (source.charAt(pos)=='+') milliseconds=-milliseconds;
date.setTime(date.getTime()+milliseconds);
pos+=6;
}
if (pos < source.length() && source.charAt(pos)=='Z') {
pos++;
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
}
if (pos < source.length())
throw new NumberFormatException(
JavaUtils.getMessage("badChars00"));
}
calendar.setTime(date);
// support dates before the Christian era
if (bc) {
calendar.set(Calendar.ERA, GregorianCalendar.BC);
}
return calendar;
}
}
1.1
xml-axis/java/src/org/apache/axis/encoding/ser/CalendarDeserializerFactory.java
Index: CalendarDeserializerFactory.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.encoding.ser;
import javax.xml.rpc.namespace.QName;
/**
* A CalendarDeserializer Factory
*
* @author Rich Scheuerle ([EMAIL PROTECTED])
*/
public class CalendarDeserializerFactory extends BaseDeserializerFactory {
public CalendarDeserializerFactory(Class javaType, QName xmlType) {
super(CalendarDeserializer.class, false, xmlType, javaType);
}
}
1.1
xml-axis/java/src/org/apache/axis/encoding/ser/CalendarSerializer.java
Index: CalendarSerializer.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.encoding.ser;
import org.xml.sax.Attributes;
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
import org.apache.axis.Constants;
import org.apache.axis.wsdl.fromJava.Types;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializationContext;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* Serializer for dateTime (Calendar).
*
* @author Sam Ruby <[EMAIL PROTECTED]>
* Modified by @author Rich scheuerle <[EMAIL PROTECTED]>
* @see <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">XML Schema 3.2.16</a>
*/
public class CalendarSerializer implements Serializer {
private static SimpleDateFormat zulu =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
// 0123456789 0 123456789
static {
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
}
/**
* Serialize a Date.
*/
public void serialize(QName name, Attributes attributes,
Object value, SerializationContext context)
throws IOException
{
context.startElement(name, attributes);
Calendar calendar = (Calendar) value;
SimpleDateFormat format =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
format.setTimeZone(calendar.getTimeZone());
Date date = calendar.getTime();
context.writeString(format.format(date));
context.endElement();
}
public String getMechanismType() { return Constants.AXIS_SAX; }
/**
* Return XML schema for the specified type, suitable for insertion into
* the <types> element of a WSDL document.
*
* @param types the Java2WSDL Types object which holds the context
* for the WSDL being generated.
* @return true if we wrote a schema, false if we didn't.
* @see org.apache.axis.wsdl.fromJava.Types
*/
public boolean writeSchema(Types types) throws Exception {
return false;
}
}
1.1
xml-axis/java/src/org/apache/axis/encoding/ser/CalendarSerializerFactory.java
Index: CalendarSerializerFactory.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.encoding.ser;
import javax.xml.rpc.namespace.QName;
/**
* SerializerFactory for Calendar(dateTime) primitives
*
* @author Rich Scheuerle <[EMAIL PROTECTED]>
*/
public class CalendarSerializerFactory extends BaseSerializerFactory {
public CalendarSerializerFactory(Class javaType, QName xmlType) {
super(CalendarSerializer.class, true, xmlType, javaType); // true
indicates shared class
}
}
1.14 +2 -0
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java
Index: JavaImplWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JavaImplWriter.java 19 Mar 2002 20:15:28 -0000 1.13
+++ JavaImplWriter.java 31 Mar 2002 23:09:34 -0000 1.14
@@ -188,6 +188,8 @@
pw.print("new byte[0]");
} else if (paramType.equals("java.lang.Byte[]")) {
pw.print("new java.lang.Byte[0]");
+ } else if (paramType.equals("java.util.Calendar")) {
+ pw.print("java.util.Calendar.getInstance()");
} else {
pw.print("new " + paramType + "()");
}
1.19 +2 -0
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java
Index: JavaTestCaseWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JavaTestCaseWriter.java 19 Mar 2002 20:15:28 -0000 1.18
+++ JavaTestCaseWriter.java 31 Mar 2002 23:09:34 -0000 1.19
@@ -258,6 +258,8 @@
pw.print("new java.lang.String()");
} else if (paramType.equals("byte[]")) {
pw.print("new byte[0]");
+ } else if (paramType.equals("java.util.Calendar")) {
+ pw.print("java.util.Calendar.getInstance()");
} else if (paramType.endsWith("[]")) {
pw.print("new "
+ JavaUtils.replace(paramType, "[]", "[0]"));
1.24 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Utils.java 20 Mar 2002 20:53:56 -0000 1.23
+++ Utils.java 31 Mar 2002 23:09:34 -0000 1.24
@@ -550,7 +550,7 @@
else if (typeValue.equals("java.math.BigInteger")) {
return "javax.xml.rpc.holders.BigIntegerHolder";
}
- else if (typeValue.equals("java.util.Date")) {
+ else if (typeValue.equals("java.util.Date")) {
return "javax.xml.rpc.holders.DateHolder";
}
else if (typeValue.equals("java.util.Calendar")) {
1.9 +31 -7 xml-axis/java/test/encoding/TestDeser2001.java
Index: TestDeser2001.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser2001.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TestDeser2001.java 8 Feb 2002 23:18:54 -0000 1.8
+++ TestDeser2001.java 31 Mar 2002 23:09:34 -0000 1.9
@@ -22,16 +22,30 @@
*/
public void testMinDate() throws Exception {
Calendar date = Calendar.getInstance();
- date.set(1999,04,31,12,01,30);
+ date.set(1999, 04, 31, 0, 0, 0);
+ date.set(Calendar.MILLISECOND,0);
+ date.setTimeZone(TimeZone.getTimeZone("GMT"));
+ deserialize("<result xsi:type=\"xsd:date\">" +
+ "1999-05-31" +
+ "</result>",
+ date.getTime());
+ }
+
+ /**
+ * Test deserialization of dateTime (Calendar) responses
+ */
+ public void testMinDateTime() throws Exception {
+ Calendar date = Calendar.getInstance();
+ date.set(1999,04,31, 12, 01, 30);
date.setTimeZone(TimeZone.getTimeZone("GMT"));
date.set(Calendar.MILLISECOND,0);
deserialize("<result xsi:type=\"xsd:dateTime\">" +
- "1999-05-31T12:01:30" +
+ "1999-05-31T12:01:30Z" +
"</result>",
- date.getTime());
+ date);
}
- public void testDateZ() throws Exception {
+ public void testDateTimeZ() throws Exception {
Calendar date = Calendar.getInstance();
date.set(1999,04,31,12,01,30);
date.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -39,18 +53,28 @@
deserialize("<result xsi:type=\"xsd:dateTime\">" +
"1999-05-31T12:01:30.150Z" +
"</result>",
- date.getTime());
+ date);
}
public void testDateTZ() throws Exception {
Calendar date = Calendar.getInstance();
+ date.set(1999, 04, 31, 0, 0, 0);
+ date.setTimeZone(TimeZone.getTimeZone("GMT"));
+ date.set(Calendar.MILLISECOND,0);
+ deserialize("<result xsi:type=\"xsd:date\">" +
+ "1999-05-31" +
+ "</result>",
+ date.getTime());
+ }
+
+ public void testDateTimeTZ() throws Exception {
+ Calendar date = Calendar.getInstance();
date.set(1999,04,31,12,01,30);
- date.setTimeZone(TimeZone.getTimeZone("GMT-05:00"));
date.set(Calendar.MILLISECOND,150);
deserialize("<result xsi:type=\"xsd:dateTime\">" +
"1999-05-31T12:01:30.150-05:00" +
"</result>",
- date.getTime());
+ date);
}
public void testBase64() throws Exception {
1.5 +2 -2 xml-axis/java/test/wsdl/roundtrip/BondInvestment.java
Index: BondInvestment.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/roundtrip/BondInvestment.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BondInvestment.java 6 Mar 2002 19:35:50 -0000 1.4
+++ BondInvestment.java 31 Mar 2002 23:09:34 -0000 1.5
@@ -57,7 +57,7 @@
import java.math.BigInteger;
import java.math.BigDecimal;
-import java.util.Date;
+import java.util.Calendar;
import test.wsdl.roundtrip.CallOptions;
/**
@@ -81,7 +81,7 @@
private String tradeExchange;
public BigInteger portfolioType;
public BigDecimal bondAmount;
- public Date callableDate;
+ public Calendar callableDate;
public byte[] byteArray;
private short[] shortArray;
private Boolean wrapperBoolean;
1.2 +2 -2 xml-axis/java/test/wsdl/roundtrip/CallOptions.java
Index: CallOptions.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/roundtrip/CallOptions.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CallOptions.java 12 Feb 2002 22:10:19 -0000 1.1
+++ CallOptions.java 31 Mar 2002 23:09:34 -0000 1.2
@@ -55,7 +55,7 @@
package test.wsdl.roundtrip;
-import java.util.Date;
+import java.util.Calendar;
/**
* The CallOptions class is just a class to determine how
@@ -67,7 +67,7 @@
public class CallOptions {
private double callPrice = 103.30;
- public Date callDate;
+ public Calendar callDate;
public static void main(String[] args) {
1.3 +5 -2 xml-axis/java/test/wsdl/roundtrip/RoundtripPortType.java
Index: RoundtripPortType.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/roundtrip/RoundtripPortType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RoundtripPortType.java 20 Feb 2002 20:41:14 -0000 1.2
+++ RoundtripPortType.java 31 Mar 2002 23:09:34 -0000 1.3
@@ -93,7 +93,9 @@
throws java.rmi.RemoteException;
public java.math.BigDecimal methodBigDecimal(java.math.BigDecimal inDecimal)
throws java.rmi.RemoteException;
- public java.util.Date methodDateTime(java.util.Date inDateTime)
+ public java.util.Date methodDate(java.util.Date inDate)
+ throws java.rmi.RemoteException;
+ public java.util.Calendar methodDateTime(java.util.Calendar inDateTime)
throws java.rmi.RemoteException;
public byte[] methodByteArray(byte[] inByteArray)
throws java.rmi.RemoteException;
@@ -102,7 +104,8 @@
public void methodAllTypesIn(java.lang.String string,
java.math.BigInteger integer,
java.math.BigDecimal decimal,
- java.util.Date dateTime,
+ java.util.Date date,
+ java.util.Calendar dateTime,
boolean _boolean,
byte _byte,
short _short,
1.6 +83 -19
xml-axis/java/test/wsdl/roundtrip/RoundtripTestServiceTestCase.java
Index: RoundtripTestServiceTestCase.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/test/wsdl/roundtrip/RoundtripTestServiceTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RoundtripTestServiceTestCase.java 6 Mar 2002 19:35:50 -0000 1.5
+++ RoundtripTestServiceTestCase.java 31 Mar 2002 23:09:34 -0000 1.6
@@ -55,8 +55,9 @@
package test.wsdl.roundtrip;
-
+import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
import java.math.BigInteger;
import java.math.BigDecimal;
@@ -203,9 +204,16 @@
CallOptions[] callOptions = new CallOptions[2];
callOptions[0] = new CallOptions();
- callOptions[0].setCallDate(new Date(1013441507388L));
+ Calendar date = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507388L));
+ callOptions[0].setCallDate(date);
callOptions[1] = new CallOptions();
- callOptions[1].setCallDate(new Date(1013441507390L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507390L));
+ callOptions[1].setCallDate(date);
short[] shortArray = {(short) 30};
byte[] byteArray = {(byte) 1};
@@ -227,7 +235,10 @@
sendValue.setWrapperBoolean(new Boolean(true));
sendValue.setShortArray(shortArray);
sendValue.setByteArray(byteArray);
- sendValue.setCallableDate(new Date(1012937861996L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1012937861996L));
+ sendValue.setCallableDate(date);
sendValue.setBondAmount(new BigDecimal("2675.23"));
sendValue.setPortfolioType(new BigInteger("2093"));
sendValue.setTradeExchange("NYSE");
@@ -239,12 +250,14 @@
sendValue.setTaxIndicator((byte) 3);
BondInvestment actual = binding.methodBondInvestmentInOut(sendValue);
+ date.setTime(new Date(1013441507308L));
assertEquals("The expected and actual values did not match.",
- new Date(1013441507308L),
+ date,
actual.getOptions()[0].getCallDate());
+ date.setTime(new Date(1013441507328L));
assertEquals("The expected and actual values did not match.",
- new Date(1013441507328L),
+ date,
actual.getOptions()[1].getCallDate());
assertEquals("The expected and actual values did not match.",
new Short((short) 33),
@@ -281,9 +294,10 @@
actual.getShortArray()[0]);
assertEquals("The expected and actual values did not match.",
(byte) 7,
- actual.getByteArray()[0]);
+ actual.getByteArray()[0]);
+ date.setTime(new Date(1012937862997L));
assertEquals("The expected and actual values did not match.",
- new Date(1012937862997L),
+ date,
actual.getCallableDate());
assertEquals("The expected and actual values did not match.",
new BigDecimal("2735.23"),
@@ -331,11 +345,16 @@
try {
BondInvestment actual = binding.methodBondInvestmentOut();
+ Calendar date = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507308L));
assertEquals("The expected and actual values did not match.",
- new Date(1013441507308L),
+ date,
actual.getOptions()[0].getCallDate());
+ date.setTime(new Date(1013441507328L));
assertEquals("The expected and actual values did not match.",
- new Date(1013441507328L),
+ date,
actual.getOptions()[1].getCallDate());
assertEquals("The expected and actual values did not match.",
new Short((short) 33),
@@ -373,8 +392,9 @@
assertEquals("The expected and actual values did not match.",
(byte) 7,
actual.getByteArray()[0]);
+ date.setTime(new Date(1012937862997L));
assertEquals("The expected and actual values did not match.",
- new Date(1012937862997L),
+ date,
actual.getCallableDate());
assertEquals("The expected and actual values did not match.",
new BigDecimal("2735.23"),
@@ -423,9 +443,16 @@
CallOptions[] callOptions = new CallOptions[2];
callOptions[0] = new CallOptions();
- callOptions[0].setCallDate(new Date(1013441507388L));
+ Calendar date = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507388L));
+ callOptions[0].setCallDate(date);
callOptions[1] = new CallOptions();
- callOptions[1].setCallDate(new Date(1013441507390L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507390L));
+ callOptions[1].setCallDate(date);
short[] shortArray = {(short) 30};
byte[] byteArray = {(byte) 1};
@@ -447,7 +474,10 @@
sendValue.setWrapperBoolean(new Boolean(true));
sendValue.setShortArray(shortArray);
sendValue.setByteArray(byteArray);
- sendValue.setCallableDate(new Date(1012937861996L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1012937861996L));
+ sendValue.setCallableDate(date);
sendValue.setBondAmount(new BigDecimal("2675.23"));
sendValue.setPortfolioType(new BigInteger("2093"));
sendValue.setTradeExchange("NYSE");
@@ -613,10 +643,15 @@
try {
byte[] sendByteArray = {(byte) 5, (byte) 10, (byte) 12};
Byte[] sendWrapperByteArray = {new Byte((byte) 9), new Byte((byte) 7)};
+ Calendar dateTime = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ dateTime.setTimeZone(gmt);
+ dateTime.setTime(new Date(1012937861986L));
binding.methodAllTypesIn(new String("Request methodAllTypesIn"),
new BigInteger("545"),
new BigDecimal("546.545"),
- new Date(1012937861986L),
+ new Date(1017532800000L),
+ dateTime,
true,
(byte) 2,
(short) 14,
@@ -687,11 +722,35 @@
* Test to insure that a Date object matches the expected values
* on both the client and server.
*/
+ public void testMethodDate() {
+
+ try {
+ Date expected = new Date(1017532800000L);
+ Date actual = binding.methodDate(new Date(1017532800000L));
+ assertEquals("The expected and actual values did not match.",
+ expected,
+ actual);
+ } catch (RemoteException re) {
+ fail("Remote Exception caught: " + re);
+ }
+
+ } // testMethodDateTime
+
+ /**
+ * Test to insure that a Calendar object matches the expected values
+ * on both the client and server.
+ */
public void testMethodDateTime() {
try {
- Date expected = new Date(1012937861800L);
- Date actual = binding.methodDateTime(new Date(1012937861996L));
+ Calendar expected = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ expected.setTimeZone(gmt);
+ expected.setTime(new Date(1012937861800L));
+ Calendar parameter = Calendar.getInstance();
+ parameter.setTimeZone(gmt);
+ parameter.setTime(new Date(1012937861996L));
+ Calendar actual = binding.methodDateTime(parameter);
assertEquals("The expected and actual values did not match.",
expected,
actual);
@@ -893,11 +952,16 @@
try {
CallOptions[] callOptions = new CallOptions[1];
callOptions[0] = new CallOptions();
- callOptions[0].setCallDate(new Date(1013459984577L));
+ Calendar cal = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ cal.setTimeZone(gmt);
+ cal.setTime(new Date(1013459984577L));
+ callOptions[0].setCallDate(cal);
CallOptions[] actual = binding.methodCallOptions(callOptions);
+ cal.setTime(new Date(1013459984507L));
assertEquals("The expected and actual values did not match.",
- new Date(1013459984507L),
+ cal,
actual[0].getCallDate());
} catch(RemoteException re) {
fail("Remote Exception caught: " + re);
1.6 +105 -25
xml-axis/java/test/wsdl/roundtrip/RoundtripTestSoapBindingImpl.java
Index: RoundtripTestSoapBindingImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/test/wsdl/roundtrip/RoundtripTestSoapBindingImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RoundtripTestSoapBindingImpl.java 6 Mar 2002 19:35:50 -0000 1.5
+++ RoundtripTestSoapBindingImpl.java 31 Mar 2002 23:09:34 -0000 1.6
@@ -55,7 +55,9 @@
package test.wsdl.roundtrip;
+import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -120,9 +122,16 @@
byte[] byteArray = {(byte) 7};
CallOptions[] callOptions = new CallOptions[2];
callOptions[0] = new CallOptions();
- callOptions[0].setCallDate(new Date(1013441507308L));
+ Calendar date = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507308L));
+ callOptions[0].setCallDate(date);
callOptions[1] = new CallOptions();
- callOptions[1].setCallDate(new Date(1013441507328L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507328L));
+ callOptions[1].setCallDate(date);
Short[] wrapperShortArray = {new Short((short) 33), new Short((short) 86)};
Byte[] wrapperByteArray = {new Byte((byte) 4), new Byte((byte) 18)};
@@ -142,7 +151,10 @@
sendValue.setWrapperBoolean(new Boolean(false));
sendValue.setShortArray(shortArray);
sendValue.setByteArray(byteArray);
- sendValue.setCallableDate(new Date(1012937862997L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1012937862997L));
+ sendValue.setCallableDate(date);
sendValue.setBondAmount(new BigDecimal("2735.23"));
sendValue.setPortfolioType(new BigInteger("21093"));
sendValue.setTradeExchange("AMEX");
@@ -157,13 +169,28 @@
(in0.getDocType() == (short) 35) &&
(in0.getTaxIndicator() == (byte) 3))
;
- else
+ else
throw new RemoteException("Actual attribute values did not match
expected values.");
- if ((in0.getOptions()[0].getCallDate().equals(new Date(1013441507388L))) &&
- (in0.getOptions()[1].getCallDate().equals(new Date(1013441507390L))) &&
- (((CallOptions[])in0.getOptions2())[0].getCallDate().equals(new
Date(1013441507388L))) &&
- (((CallOptions[])in0.getOptions2())[1].getCallDate().equals(new
Date(1013441507390L))) &&
+ Calendar expectedDate0 = Calendar.getInstance();
+ expectedDate0.setTimeZone(gmt);
+ expectedDate0.setTime(new Date(1013441507388L));
+ Calendar expectedDate1 = Calendar.getInstance();
+ expectedDate1.setTimeZone(gmt);
+ expectedDate1.setTime(new Date(1013441507390L));
+ Calendar expectedDate2 = Calendar.getInstance();
+ expectedDate2.setTimeZone(gmt);
+ expectedDate2.setTime(new Date(1013441507388L));
+ Calendar expectedDate3 = Calendar.getInstance();
+ expectedDate3.setTimeZone(gmt);
+ expectedDate3.setTime(new Date(1013441507390L));
+ Calendar expectedDate4 = Calendar.getInstance();
+ expectedDate4.setTimeZone(gmt);
+ expectedDate4.setTime(new Date(1012937861996L));
+ if ((in0.getOptions()[0].getCallDate().equals(expectedDate0)) &&
+ (in0.getOptions()[1].getCallDate().equals(expectedDate1)) &&
+
(((CallOptions[])in0.getOptions2())[0].getCallDate().equals(expectedDate2)) &&
+
(((CallOptions[])in0.getOptions2())[1].getCallDate().equals(expectedDate3)) &&
(in0.getWrapperShortArray()[0].equals(new Short((short) 23))) &&
(in0.getWrapperShortArray()[1].equals(new Short((short) 56))) &&
(in0.getWrapperByteArray()[0].equals(new Byte((byte) 2))) &&
@@ -176,7 +203,7 @@
(in0.getWrapperBoolean().equals(new Boolean(true))) &&
(in0.getShortArray()[0] == (short) 30) &&
(in0.getByteArray()[0] == (byte) 1) &&
- (in0.getCallableDate().equals(new Date(1012937861996L))) &&
+ (in0.getCallableDate().equals(expectedDate4)) &&
(in0.getBondAmount().equals(new BigDecimal("2675.23"))) &&
(in0.getPortfolioType().equals(new BigInteger("2093"))) &&
(in0.getTradeExchange().equals("NYSE")) &&
@@ -199,9 +226,16 @@
byte[] byteArray = {(byte) 7};
CallOptions[] callOptions = new CallOptions[2];
callOptions[0] = new CallOptions();
- callOptions[0].setCallDate(new Date(1013441507308L));
+ Calendar date = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507308L));
+ callOptions[0].setCallDate(date);
callOptions[1] = new CallOptions();
- callOptions[1].setCallDate(new Date(1013441507328L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1013441507328L));
+ callOptions[1].setCallDate(date);
Short[] wrapperShortArray = {new Short((short) 33), new Short((short) 86)};
Byte[] wrapperByteArray = {new Byte((byte) 4), new Byte((byte) 18)};
@@ -220,7 +254,10 @@
sendValue.setWrapperBoolean(new Boolean(false));
sendValue.setShortArray(shortArray);
sendValue.setByteArray(byteArray);
- sendValue.setCallableDate(new Date(1012937862997L));
+ date = Calendar.getInstance();
+ date.setTimeZone(gmt);
+ date.setTime(new Date(1012937862997L));
+ sendValue.setCallableDate(date);
sendValue.setBondAmount(new BigDecimal("2735.23"));
sendValue.setPortfolioType(new BigInteger("21093"));
sendValue.setTradeExchange("AMEX");
@@ -236,11 +273,26 @@
} // methodBondInvestmentOut
public void methodBondInvestmentIn(BondInvestment in0) throws RemoteException {
-
- if (!((in0.getOptions()[0].getCallDate().equals(new Date(1013441507388L)))
&&
- (in0.getOptions()[1].getCallDate().equals(new Date(1013441507390L)))
&&
- (((CallOptions[])in0.getOptions2())[0].getCallDate().equals(new
Date(1013441507388L))) &&
- (((CallOptions[])in0.getOptions2())[1].getCallDate().equals(new
Date(1013441507390L))) &&
+ Calendar expectedDate0 = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ expectedDate0.setTimeZone(gmt);
+ expectedDate0.setTime(new Date(1013441507388L));
+ Calendar expectedDate1 = Calendar.getInstance();
+ expectedDate1.setTimeZone(gmt);
+ expectedDate1.setTime(new Date(1013441507390L));
+ Calendar expectedDate2 = Calendar.getInstance();
+ expectedDate2.setTimeZone(gmt);
+ expectedDate2.setTime(new Date(1013441507388L));
+ Calendar expectedDate3 = Calendar.getInstance();
+ expectedDate3.setTimeZone(gmt);
+ expectedDate3.setTime(new Date(1013441507390L));
+ Calendar expectedDate4 = Calendar.getInstance();
+ expectedDate4.setTimeZone(gmt);
+ expectedDate4.setTime(new Date(1012937861996L));
+ if (!((in0.getOptions()[0].getCallDate().equals(expectedDate0)) &&
+ (in0.getOptions()[1].getCallDate().equals(expectedDate1)) &&
+
(((CallOptions[])in0.getOptions2())[0].getCallDate().equals(expectedDate2)) &&
+
(((CallOptions[])in0.getOptions2())[1].getCallDate().equals(expectedDate3)) &&
(in0.getWrapperShortArray()[0].equals(new Short((short) 23))) &&
(in0.getWrapperShortArray()[1].equals(new Short((short) 56))) &&
(in0.getWrapperByteArray()[0].equals(new Byte((byte) 2))) &&
@@ -253,7 +305,7 @@
(in0.getWrapperBoolean().equals(new Boolean(true))) &&
(in0.getShortArray()[0] == (short) 30) &&
(in0.getByteArray()[0] == (byte) 1) &&
- (in0.getCallableDate().equals(new Date(1012937861996L))) &&
+ (in0.getCallableDate().equals(expectedDate4)) &&
(in0.getBondAmount().equals(new BigDecimal("2675.23"))) &&
(in0.getPortfolioType().equals(new BigInteger("2093"))) &&
(in0.getTradeExchange().equals("NYSE")) &&
@@ -340,6 +392,7 @@
BigInteger in1,
BigDecimal in2,
Date in3,
+ Calendar in35,
boolean in4,
byte in5,
short in6,
@@ -356,10 +409,15 @@
Float in18,
Double in19,
Byte[] in12) throws RemoteException {
+ Calendar expectedDateTime = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ expectedDateTime.setTimeZone(gmt);
+ expectedDateTime.setTime(new Date(1012937861986L));
if (!((in0.equals(new String("Request methodAllTypesIn"))) &&
(in1.equals(new BigInteger("545"))) &&
(in2.equals(new BigDecimal("546.545"))) &&
- (in3.equals(new Date(1012937861986L))) &&
+ (in3.equals(new Date(1017532800000L))) &&
+ (in35.equals(expectedDateTime)) &&
(in13.equals(new Boolean(false))) &&
(in14.equals(new Byte((byte) 11))) &&
(in15.equals(new Short((short) 45))) &&
@@ -409,16 +467,34 @@
} // methodByteArray
- public Date methodDateTime(Date in0) throws RemoteException {
+ public Date methodDate(Date in0) throws RemoteException {
- Date expectedDate = new Date(1012937861996L);
+ Date expectedDate = new Date(1017532800000L);
if (in0.equals(expectedDate)) {
- return new Date(1012937861800L);
+ return new Date(1017532800000L);
} else {
throw new RemoteException("Expecting a Date value of " + expectedDate +
".");
}
+ } // methodDate
+
+ public Calendar methodDateTime(Calendar in0) throws RemoteException {
+
+ Calendar expectedDateTime = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ expectedDateTime.setTimeZone(gmt);
+ expectedDateTime.setTime(new Date(1012937861996L));
+
+ if (in0.equals(expectedDateTime)) {
+ Calendar dateTime = Calendar.getInstance();
+ dateTime.setTimeZone(gmt);
+ dateTime.setTime(new Date(1012937861800L));
+ return dateTime;
+ } else {
+ throw new RemoteException("Expecting a Date value of " +
expectedDateTime + ".");
+ }
+
} // methodDateTime
public BigDecimal methodBigDecimal(BigDecimal in0) throws RemoteException {
@@ -522,10 +598,14 @@
} // methodBoolean
public CallOptions[] methodCallOptions(CallOptions[] in0) throws
RemoteException {
-
- if (in0[0].getCallDate().equals(new Date(1013459984577L))) {
+ Calendar dateTime = Calendar.getInstance();
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ dateTime.setTimeZone(gmt);
+ dateTime.setTime(new Date(1013459984577L));
+ if (in0[0].getCallDate().equals(dateTime)) {
in0[0] = new CallOptions();
- in0[0].setCallDate(new Date(1013459984507L));
+ dateTime.setTime(new Date(1013459984507L));
+ in0[0].setCallDate(dateTime);
return in0;
} else {
throw new RemoteException("Actual value did not match expected value.");
1.22 +30 -0 xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
Index: ComprehensiveTypes.wsdl
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ComprehensiveTypes.wsdl 26 Mar 2002 22:51:25 -0000 1.21
+++ ComprehensiveTypes.wsdl 31 Mar 2002 23:09:34 -0000 1.22
@@ -317,6 +317,7 @@
<part name="boolean" type="xsd:boolean"/>
<part name="byte" type="xsd:byte"/>
<part name="QName" type="xsd:QName"/>
+ <part name="date" type="xsd:date"/>
<part name="dateTime" type="xsd:dateTime"/>
<part name="base64Binary" type="xsd:base64Binary"/>
<part name="hexBinary" type="xsd:hexBinary"/>
@@ -429,6 +430,16 @@
<part name="decimal" type="xsd:decimal"/>
</message>
+ <message name="inputDate">
+ <part name="inDate" type="xsd:date"/>
+ <part name="date" type="xsd:date"/>
+ </message>
+
+ <message name="outputDate">
+ <part name="outDate" type="xsd:date"/>
+ <part name="date" type="xsd:date"/>
+ </message>
+
<message name="inputDateTime">
<part name="inDateTime" type="xsd:dateTime"/>
<part name="dateTime" type="xsd:dateTime"/>
@@ -765,6 +776,10 @@
<input message="tns:inputDecimal"/>
<output message="tns:outputDecimal"/>
</operation>
+ <operation name="methodDate">
+ <input message="tns:inputDate"/>
+ <output message="tns:outputDate"/>
+ </operation>
<operation name="methodDateTime">
<input message="tns:inputDateTime"/>
<output message="tns:outputDateTime"/>
@@ -1473,6 +1488,21 @@
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
+ <operation name="methodDate">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
<operation name="methodDateTime">
<soap:operation soapAction=""/>
<input>
1.17 +41 -4 xml-axis/java/test/wsdl/types/VerifyTestCase.java
Index: VerifyTestCase.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/types/VerifyTestCase.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- VerifyTestCase.java 20 Mar 2002 20:53:57 -0000 1.16
+++ VerifyTestCase.java 31 Mar 2002 23:09:34 -0000 1.17
@@ -7,6 +7,9 @@
package test.wsdl.types;
+import java.util.Date;
+import java.util.Calendar;
+
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.holders.BigDecimalHolder;
@@ -16,6 +19,7 @@
import javax.xml.rpc.holders.ByteArrayHolder;
import javax.xml.rpc.holders.ByteWrapperArrayHolder;
import javax.xml.rpc.holders.ByteHolder;
+import javax.xml.rpc.holders.CalendarHolder;
import javax.xml.rpc.holders.DateHolder;
import javax.xml.rpc.holders.DoubleWrapperHolder;
import javax.xml.rpc.holders.DoubleHolder;
@@ -82,7 +86,30 @@
}
assertTrue("binding is null", binding != null);
try {
- binding.allPrimitivesIn("hi", new java.math.BigInteger("5"), 0, (long)
0, (short) 0, new java.math.BigDecimal(6), (float) 0, (double) 0, true, (byte) 0, new
QName("hi", "ho"), new java.util.Date(), new byte[]{(byte) 5}, new byte[]{(byte) 6},
"hi ho", new Boolean(true), new Float(0), new Double(0), new java.math.BigDecimal(7),
new Integer(0), new Short((short) 0), new Byte[]{new Byte((byte) 7)});
+ binding.allPrimitivesIn(
+ "hi",
+ new java.math.BigInteger("5"),
+ 0,
+ (long) 0,
+ (short) 0,
+ new java.math.BigDecimal(6),
+ (float) 0,
+ (double) 0,
+ true,
+ (byte) 0,
+ new QName("hi", "ho"),
+ new Date(),
+ Calendar.getInstance(),
+ new byte[]{(byte) 5},
+ new byte[]{(byte) 6},
+ "hi ho",
+ new Boolean(true),
+ new Float(0),
+ new Double(0),
+ new java.math.BigDecimal(7),
+ new Integer(0),
+ new Short((short) 0),
+ new Byte[]{new Byte((byte) 7)});
} catch (java.rmi.RemoteException re) {
throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re );
}
@@ -99,7 +126,8 @@
new BooleanHolder(true),
new ByteHolder((byte) 7),
new QNameHolder(new QName("ho", "hi")),
- new DateHolder(new java.util.Date()),
+ new DateHolder(new Date()),
+ new CalendarHolder(Calendar.getInstance()),
new ByteArrayHolder(new byte[]{(byte) 8}),
new ByteArrayHolder(new byte[]{(byte) 9}),
new StringHolder("ho hi"),
@@ -127,6 +155,7 @@
new ByteHolder(),
new QNameHolder(),
new DateHolder(),
+ new CalendarHolder(),
new ByteArrayHolder(),
new ByteArrayHolder(),
new StringHolder(),
@@ -430,9 +459,17 @@
throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re );
}
try {
- java.util.Date sendValue = new java.util.Date(1012182070626L);
+ Date sendValue = new Date(1012182070626L);
DateHolder dh = new DateHolder(sendValue);
- java.util.Date actual = binding.methodDateTime(sendValue, dh);
+ Date actual = binding.methodDate(sendValue, dh);
+ } catch (java.rmi.RemoteException re) {
+ throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re );
+ }
+ try {
+ Calendar sendValue = Calendar.getInstance();
+ sendValue.setTime(new Date(1012182070626L));
+ CalendarHolder ch = new CalendarHolder(sendValue);
+ Calendar actual = binding.methodDateTime(sendValue, ch);
} catch (java.rmi.RemoteException re) {
throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re );
}