Hello Tom,

As java.util.Calendar is an abstract class, it cannot be instantiated. When you call Calendar.getInstance(), you create an instance of GregorianCalendar (similar to Calendar gregCal = new GregorianCalendar(2021,02,01); -> Axis would not even know the difference).
The former is the way you should use Calendar types.

I lost your original e-mail, but I assume you used WSDL2Java and got a class called LabTestAuthorization with a field called lastDateModified of type java.util.Calendar?

I don't understand how MyClass fits in the picture. There is no complexType called MyClass in your WSDL.

Could you show the stacktrace of the ClassCastException and the source (your client and/or generated Javabean) it occurs in?

Regards,
Dies


Tom Bollwitt wrote:
ok, I should probably be more clear on what I am doing with the
Calendar.
I have a class i.e. MyClass.java.
Within MyClass there is a private Calendar lastDateModified; with
getter/setter.
I want to RETURN  MyClass to the client. The client will do nothing with
dates, just receive the MyClass object from the web service.
The lastDateModified is set by with: Calendar.getInstance(). Nowhere in
my code am I using GregorianCalendar.
When i use a test client to make the call it gets the
java.lang.ClassCastException: java.util.GregorianCalendar.
I created the Interface for the service along with the objects it
depends on, i.e. the MyClass object. I then used the Java2Wsdl to
generate the wsdl file.
I then used Wsdl2Java to generate the the Java classes and the
deploy/undeploy.wsdd files.
Is there something the Wsdle2Java generation is leaving out? If I remove
the Calendar attribute everything works.
Here is my latest version of the wsdl. and deploy.wsdd WSDL:
<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions targetNamespace="urn:AuthorizeLabTest"
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:impl="urn:AuthorizeLabTest" xmlns:intf="urn:AuthorizeLabTest"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:tns2="http://model.webservice.crlcorp.com";
xmlns:tns3="http://datautil.crlcorp.com";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

<!--WSDL created by Apache Axis version: 1.3

Built on Oct 05, 2005 (05:23:37 EDT)-->

<wsdl:types>

<schema targetNamespace="http://model.webservice.crlcorp.com";
xmlns="http://www.w3.org/2001/XMLSchema";>

<import namespace="urn:AuthorizeLabTest"/>

<import namespace="http://datautil.crlcorp.com"/>

<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="AuthorizationRequest">

<sequence>

<element name="bloodState" nillable="true" type="soapenc:string"/>

<element name="cocID" nillable="true" type="soapenc:string"/>

<element name="urinState" nillable="true" type="soapenc:string"/>

<element name="userId" nillable="true" type="soapenc:string"/>

<element name="userPwd" nillable="true" type="soapenc:string"/>

</sequence>

</complexType>

<complexType name="AuthorizationResult">

<sequence>

<element name="bloodMessage" nillable="true" type="soapenc:string"/>

<element name="cocId" nillable="true" type="soapenc:string"/>

<element name="message" nillable="true" type="soapenc:string"/>

<element name="urinMessage" nillable="true" type="soapenc:string"/>

</sequence>

</complexType>

<complexType name="LabTestAuthorization">

<sequence>

<element name="bloodTestState" nillable="true" type="soapenc:string"/>

<element name="cocID" nillable="true" type="soapenc:string"/>

<element name="id" nillable="true" type="soapenc:long"/>

<element name="urinTestState" nillable="true" type="soapenc:string"/>

<element name="lastDateModified" nillable="true" type="xsd:dateTime"/>

</sequence>

</complexType>

<simpleType name="TestStates">

<restriction base="soapenc:string">

<enumeration value="approved"/>

<enumeration value="approval pending"/>

<enumeration value="approval canceled"/>

<enumeration value="approval suspended"/>

<enumeration value="approval denied"/>

<enumeration value="unknown"/>

</restriction>

</simpleType>

</schema>

<schema targetNamespace="http://datautil.crlcorp.com";
xmlns="http://www.w3.org/2001/XMLSchema";>

<import namespace="urn:AuthorizeLabTest"/>

<import namespace="http://model.webservice.crlcorp.com"/>

<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="DatabaseException">

<sequence/>

</complexType>

</schema>

<schema targetNamespace="urn:AuthorizeLabTest"
xmlns="http://www.w3.org/2001/XMLSchema";>

<import namespace="http://datautil.crlcorp.com"/>

<import namespace="http://model.webservice.crlcorp.com"/>

<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="ArrayOf_tns2_LabTestAuthorization">

<complexContent>

<restriction base="soapenc:Array">

<attribute ref="soapenc:arrayType"
wsdl:arrayType="tns2:LabTestAuthorization[]"/>

</restriction>

</complexContent>

</complexType>

</schema>

</wsdl:types>

<wsdl:message name="getAuthorizationsResponse">

<wsdl:part name="getAuthorizationsReturn"
type="impl:ArrayOf_tns2_LabTestAuthorization"/>

</wsdl:message>

<wsdl:message name="getAuthorizationByCocIdResponse">

<wsdl:part name="getAuthorizationByCocIdReturn"
type="tns2:LabTestAuthorization"/>

</wsdl:message>

<wsdl:message name="getAuthorizationByCocIdRequest">

<wsdl:part name="in0" type="soapenc:string"/>

</wsdl:message>

<wsdl:message name="getAuthorizationsRequest">

</wsdl:message>

<wsdl:message name="DatabaseException">

<wsdl:part name="fault" type="tns3:DatabaseException"/>

</wsdl:message>

<wsdl:message name="processAuthorizationRequest">

<wsdl:part name="in0" type="tns2:AuthorizationRequest"/>

</wsdl:message>

<wsdl:message name="processAuthorizationResponse">

<wsdl:part name="processAuthorizationReturn"
type="tns2:AuthorizationResult"/>

</wsdl:message>

<wsdl:portType name="AuthorizeLabTest">

<wsdl:operation name="processAuthorization" parameterOrder="in0">

<wsdl:input message="impl:processAuthorizationRequest"
name="processAuthorizationRequest"/>

<wsdl:output message="impl:processAuthorizationResponse"
name="processAuthorizationResponse"/>

<wsdl:fault message="impl:DatabaseException" name="DatabaseException"/>

</wsdl:operation>

<wsdl:operation name="getAuthorizations">

<wsdl:input message="impl:getAuthorizationsRequest"
name="getAuthorizationsRequest"/>

<wsdl:output message="impl:getAuthorizationsResponse"
name="getAuthorizationsResponse"/>

<wsdl:fault message="impl:DatabaseException" name="DatabaseException"/>

</wsdl:operation>

<wsdl:operation name="getAuthorizationByCocId" parameterOrder="in0">

<wsdl:input message="impl:getAuthorizationByCocIdRequest"
name="getAuthorizationByCocIdRequest"/>

<wsdl:output message="impl:getAuthorizationByCocIdResponse"
name="getAuthorizationByCocIdResponse"/>

<wsdl:fault message="impl:DatabaseException" name="DatabaseException"/>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="AuthorizeLabSoapBinding"
type="impl:AuthorizeLabTest">

<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="processAuthorization">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="processAuthorizationRequest">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:input>

<wsdl:output name="processAuthorizationResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:output>

<wsdl:fault name="DatabaseException">

<wsdlsoap:fault
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
name="DatabaseException" namespace="urn:AuthorizeLabTest"
use="encoded"/>

</wsdl:fault>

</wsdl:operation>

<wsdl:operation name="getAuthorizations">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="getAuthorizationsRequest">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:input>

<wsdl:output name="getAuthorizationsResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:output>

<wsdl:fault name="DatabaseException">

<wsdlsoap:fault
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
name="DatabaseException" namespace="urn:AuthorizeLabTest"
use="encoded"/>

</wsdl:fault>

</wsdl:operation>

<wsdl:operation name="getAuthorizationByCocId">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="getAuthorizationByCocIdRequest">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:input>

<wsdl:output name="getAuthorizationByCocIdResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="urn:AuthorizeLabTest" use="encoded"/>

</wsdl:output>

<wsdl:fault name="DatabaseException">

<wsdlsoap:fault
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
name="DatabaseException" namespace="urn:AuthorizeLabTest"
use="encoded"/>

</wsdl:fault>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="AuthorizeLabTestService">

<wsdl:port binding="impl:AuthorizeLabSoapBinding" name="AuthorizeLab">

<wsdlsoap:address
location="http://localhost:8080/escreen-test/services/AuthorizeLab"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

deploy.wsdd
<!-- Use this file to deploy some handlers/chains and services -->

<!-- Two ways to do this: -->

<!-- java org.apache.axis.client.AdminClient deploy.wsdd -->

<!-- after the axis server is running -->

<!-- or -->

<!-- java org.apache.axis.utils.Admin client|server deploy.wsdd -->

<!-- from the same directory that the Axis engine runs -->

<deployment

xmlns="http://xml.apache.org/axis/wsdd/";

xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>

<!-- Services from AuthorizeLabTestService WSDL service -->

<service name="AuthorizeLab" provider="java:RPC" style="rpc"
use="encoded">

<parameter name="wsdlTargetNamespace" value="urn:AuthorizeLabTest"/>

<parameter name="wsdlServiceElement" value="AuthorizeLabTestService"/>

<parameter name="schemaUnqualified"
value="http://model.webservice.crlcorp.com,http://datautil.crlcorp.com,u
rn:AuthorizeLabTest"/>

<parameter name="wsdlServicePort" value="AuthorizeLab"/>

<parameter name="className"
value="com.crlcorp.webservice.AuthorizeLabSoapBindingSkeleton"/>

<parameter name="wsdlPortType" value="AuthorizeLabTest"/>

<parameter name="typeMappingVersion" value="1.2"/>

<parameter name="allowedMethods" value="*"/>

<parameter name="scope" value="Session"/>

<typeMapping

xmlns:ns="http://model.webservice.crlcorp.com";

qname="ns:AuthorizationResult"

type="java:com.crlcorp.webservice.model.AuthorizationResult"

serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"

deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

<typeMapping

xmlns:ns="http://datautil.crlcorp.com";

qname="ns:DatabaseException"

type="java:com.crlcorp.datautil.DatabaseException"

serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"

deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

<arrayMapping

xmlns:ns="urn:AuthorizeLabTest"

qname="ns:ArrayOf_tns2_LabTestAuthorization"

type="java:com.crlcorp.webservice.model.LabTestAuthorization[]"

innerType="cmp-ns:LabTestAuthorization"
xmlns:cmp-ns="http://model.webservice.crlcorp.com";

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

<typeMapping

xmlns:ns="http://model.webservice.crlcorp.com";

qname="ns:AuthorizationRequest"

type="java:com.crlcorp.webservice.model.AuthorizationRequest"

serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"

deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

<typeMapping

xmlns:ns="http://model.webservice.crlcorp.com";

qname="ns:TestStates"

type="java:java.lang.String"

serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"

deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

<typeMapping

xmlns:ns="http://model.webservice.crlcorp.com";

qname="ns:LabTestAuthorization"

type="java:com.crlcorp.webservice.model.LabTestAuthorization"

serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"

deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";

/>

</service>

</deployment>

Thanks for the help! :)

________________________________

From: robert lazarski [mailto:[EMAIL PROTECTED] Sent: Friday, May 05, 2006 9:13 PM
To: [email protected]
Subject: Re: Calendar classCastException


I'm not sure if you can use GregorianCalendar directly with xsd:dateTime
in all databinding frameworks. I know this works:
Calendar cal = new GregorianCalendar();

And this also works:
Calendar now = Calendar.getInstance();

What may not as I've never tried it is this:
GregorianCalendar gregCal = new GregorianCalendar(2021,02,01);

And then gregCal as your param to your complex object. So I'd try a
vanilla Calendar to see if the problem is xsd:dateTime in axis 1.x
doesn't accept a sub-type of calendar.
HTH,
Robert
http://www.braziloutsource.com/

Reply via email to