You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by "Mork, Phil" <PM...@temgweb.com> on 2001/02/01 18:02:01 UTC

Date serializers

Glen,

That would be great if you could add it to the baseline. You may also want
to consider including this other attachment (DateSerializer), which maps
from an xsd:timeInstant <--> java.util.Date.  I tried to make both xsd:date
and xsd:timeInstant map to java.util.Date, but evidently a bug in SOAP 2.0
(it's since been fixed in CVS) was forcing a mapping of both
serializer/deserializer to be the same Java class(rather than using separate
ones - so you could consistently turn a java.util.Date into a timeInstant so
you don't lose data, but allow a xsd:date to go to a java.util.Date with
time zeroed out as well as allow xsd:timeInstant to map to java.util.Date).
But after clearing that up there were still some other issues. So for the
meantime I just mapped them to separate Java classes to avoid problems.  

I'm guessing the limitations I mentioned above may liked be fixed in
ApacheSOAP 2.1. What do you think is the best way to handle this longer
term?

Phil


-----Original Message-----
From: Glen Daniels [mailto:gdaniels@allaire.com]
Sent: Thursday, February 01, 2001 10:34 AM
To: 'soap-user@xml.apache.org'
Subject: RE: Unsing your own serializer



Phil:

Would you mind if I committed that serializer into the baseline ApacheSOAP
source?  I think dates would be a great addition to our corral of supported
basic types!

--Glen

> -----Original Message-----
> From: Mork, Phil [mailto:PMork@temgweb.com]
> Sent: Thursday, February 01, 2001 11:20 AM
> To: 'soap-user@xml.apache.org'
> Subject: RE: Unsing your own serializer
> 
> 
> Andrew,
> 
> Sure, here's an example of code to add a serializer/deserializer for
> xsd:date <--> java.util.GregorianCalendar. 
> 
> On the server side you must add to the deployment descriptor 
> to provide the
> mapping from the Java class you want to serialize, the QName 
> that represent
> what type name in XML to map to, and the class name of the 
> serializer and
> deserializer to use.
> 
> Say you have a SOAP service and you add a method 
> "processCalendar" in your
> service to test your new custom serializer.  So in the
> DeploymentDescriptor.xml that you use to deploy your service 
> you would add
> (in the <isd:mappings> element):
> 
>          <isd:map 
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>          xmlns:x="http://www.w3.org/1999/XMLSchema" qname="x:date"
>          javaType="java.util.GregorianCalendar"
>          java2XMLClassName="com.somecompany.soap.CalendarSerializer"
>          xml2JavaClassName="com.somecompany.soap.CalendarSerializer"/>
> 
> Then in your client code add: 
> 
>       Vector params = new Vector();
> 
>     	Calendar newCal = Calendar.getInstance();
>     	params.addElement(new Parameter("pCalendar",
> java.util.GregorianCalendar.class,
> newCal, Constants.NS_URI_SOAP_ENC));
>     	
>     	SOAPMappingRegistry smr = new SOAPMappingRegistry();
>     	CalendarSerializer calSer = new CalendarSerializer();
> 	    	
>     	smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>                 	new QName(Constants.NS_URI_SCHEMA_XSD, "date"),
>                 	java.util.GregorianCalendar.class, 
> calSer, calSer);
> 
>     	Call newCall = new Call("urn:RequestForwarder", 
> "processCalendar",
> params, 
> 					new Header(),
> Constants.NS_URI_SOAP_ENC);
>     	newCall.setSOAPMappingRegistry(smr);
> 
>         // ... invoke the call
> 
> 
> Attached is code for the CalendarSerializer.
> 
> I hope this is helpful.
> 
> Phil
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Andrew Sealy-Bell [mailto:asealybell@enterpriseis.co.uk]
> Sent: Thursday, February 01, 2001 3:36 AM
> To: soap-user@xml.apache.org
> Subject: RE: Unsing your own serializer
> 
> 
> Hi, would you mind posting an example to the newsgroup please?
> 
> -----Original Message-----
> From: Mork, Phil [mailto:PMork@temgweb.com]
> Sent: 31 January 2001 23:42
> To: 'soap-user@xml.apache.org'
> Subject: RE: Unsing your own serializer
> 
> 
> Octav,
> 
> Another comment - It looks like you're not consistent in the 
> use of your
> encoding style between your smr.mapTypes call and your 
> parameter that you
> create.  I've got a lot of working custom 
> serializer/deserilizers but I
> definitely am always consistent in the use the the encoding style when
> mapping them.
> 
> 
>  smr.mapTypes(" http://mystuff <http://mystuff> ", new
> QName("urn:ccpp-protocol","ccpp"), CCPP.class, CCPPSer, CCPPSer);
> 
>  ..      try using Constants.NS_URI_LITERAL_XML as the first 
> parameter above
> instead of  "http://mystuff"
> 
>  .
>     call.setSOAPMappingRegistry(smr);
> ...
> params.add(new Parameter("ccpp", CCPP.class, ccpp,
> Constants.NS_URI_LITERAL_XML));
> ....
> call.setParams(params);
> ...
> invoke ...
> 
> and I get the following error
> 
> Caught SOAPException (SOAP-ENV:Client): No Serializer found 
> to serialize a
> 'org.apache.soap.rpc.Parameter' using encoding style 'http://mystuff"
> 
> Any clues ...
> 
> Thanks,
> 
> 
> - Octav
> 
> -----Original Message-----
> From: Malani, Prakash [mailto:PMalani@eBuilt.com]
> Sent: Wednesday, January 31, 2001 3:59 PM
> To: 'soap-user@xml.apache.org'
> Subject: RE: Literal XML
> 
> 
> Hi,
> 
> How are you doing?  The address example that ships with SOAP 
> provides a
> decent example of using literal XML encoding.
> 
> Sincerely,
> -Prakash
> 
> 
> Hi All,
> 
> 
> Can anyone point out a place a sample using literal xml as encoding!
> 
> PLEASE !!!!!!!!!!!!!!!!
> 
> 
> Octav
> 
> 
> 
> Octav Chipara
> 
> 
> Email:
> 
> ochipara@cse.unl.edu <ma...@cse.unl.edu>
> 
> 
> Web page:
> 
> www.cse.unl.edu/~ochipara <http://www.cse.unl.edu/~ochipara>
> 
> 
> Phone:
> 
> (402) 472-9492
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org