Loading ...
Sorry, an error occurred while loading the content.

3477Re: [soaplite] Re: SOAP::Lite and dates

Expand Messages
  • Byrne Reese
    Apr 6, 2004
      Fair enough... here is a little bit on datetimes with SOAP::Lite...

      A recent module to CPAN seems to help address the problem:
      http://search.cpan.org/~mcmahon/SOAP-DateTime-0.01/

      From the README: "This is a little utility module that converts dates
      into the format required by the SOAP 'xsd:dateTime' type. It's just a
      dumb little wrapper around Date::Manip, because that's the lazy way to
      make sure that we are forgiving in what we accept."

      So there is also Date::Manip (obviously).
      http://search.cpan.org/~sbeck/DateManip-5.42a/Manip.pod

      Bottom line, SOAP::Lite doesn't (since Perl is so loosely typed) do any
      type deserialization for you. Not to anything but a SCALAR. Perhaps that
      is something we should more clearly document and provide workarounds for.

      The flip side of course is that the next version of SOAP::Lite, which
      will ship with wsdl2perl, will handle dates more gracefully and
      recognize all of their permutations. From the source of the next release
      of SOAP::Lite:

      _typelookup => {
      ...
      'gMonth' =>
      [35, sub { $_[0] =~ /^--\d\d--(-\d\d:\d\d)?$/; }, 'as_gMonth'],
      'gDay' =>
      [40, sub { $_[0] =~ /^---\d\d(-\d\d:\d\d)?$/; }, 'as_gDay'],
      'gYear' =>
      [45, sub { $_[0] =~ /^-?\d\d\d\d(-\d\d:\d\d)?$/; }, 'as_gYear'],
      'gMonthDay' =>
      [50, sub { $_[0] =~ /^-\d\d-\d\d(-\d\d:\d\d)?$/; },
      'as_gMonthDay'],
      'gYearMonth' =>
      [55, sub { $_[0] =~ /^-?\d\d\d\d-\d\d(Z|([+-]\d\d:\d\d))?$/;
      }, 'as_gYearMonth'],
      'date' =>
      [60, sub { $_[0] =~
      /^-?\d\d\d\d-\d\d-\d\d(Z|([+-]\d\d:\d\d))?$/; }, 'as_date'],
      'time' =>
      [70, sub { $_[0] =~
      /^\d\d:\d\d:\d\d(\.\d\d\d)?(Z|([+-]\d\d:\d\d))?$/; }, 'as_time'],
      'dateTime' =>
      [75, sub { $_[0] =~
      /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d\d)?(Z|([+-]\d\d:\d\d))?$/; },
      'as_dateTime'],
      'duration' =>
      [80, sub { $_[0] =~
      /^-?P(\d+Y)?(\d+M)?(\dD)?(T(\d+H)?(\d+M)?(\d+S)?)?$/; }, 'as_duration'],
      'duration' =>
      [85, sub { $_[0] =~
      /^-?P(\d+Y)?(\d+M)?(\dD)?(T(\d+H)?(\d+M)?(\d+S)?)?$/; }, 'as_duration'],
      ...
      },

      Stephane Bortzmeyer wrote:

      > On Fri, Apr 02, 2004 at 12:58:52PM +0200,
      > Stephane Bortzmeyer <bortzmeyer@...> wrote
      > a message of 41 lines which said:
      >
      > > In CPAN, I've found a SOAP::DateTime. Is it the only solution?
      >
      > Using the above module to format the date and
      > SOAP::Data->type('xsd:datetime' => XXX) to tag it properly, I can send
      > what seems to be proper SOAP elements.
      >
      > Now, how can I deserialize them in Perl? The client, also written in
      > SOAP::Lite, says:
      >
      > SOAP::Deserializer::deserialize: ()
      > SOAP::Parser::decode: ()
      > Unrecognized type '{http://www.w3.org/1999/XMLSchema}datetime'
      > <http://www.w3.org/1999/XMLSchema%7Ddatetime%27>
      >
      > while the SOAP answer is:
      >
      > <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      > xmlns:namesp6="http://xml.apache.org/xml-soap"
      > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp5:status_ticketResponse
      > xmlns:namesp5="http://nic.fr/Ticket"><s-gensym23
      > xsi:type="namesp6:SOAPStruct"><auth
      > xsi:type="xsd:string">A2950FFEAAFBAD17</auth><state
      > xsi:type="xsd:string">DNS Non Pret</state><operation
      > xsi:type="xsd:string">Creation</operation><form
      > xsi:type="xsd:int">301988</form><domain
      > xsi:type="xsd:string">logan2004.fr</domain><creation_date
      > xsi:type="xsd:datetime">2003-06-10T12:59:00</creation_date><seed
      > xsi:type="xsd:int">442724</seed><remark xsi:type="xsd:string">Nouvel
      > Etat: DNS Non Pret
      > </remark><modification_date
      > xsi:type="xsd:datetime">2003-07-10T10:50:00</modification_date><number
      > xsi:type="xsd:string">NIC000000500893</number></s-gensym23></namesp5:status_ticketResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
      >
      >
      > The question "How to deserialize datetimes?" seem to come up often on
      > that list but not the answer :-}
      >
      > ------------------------------------------------------------------------
      > *Yahoo! Groups Links*
      >
      > * To visit your group on the web, go to:
      > http://groups.yahoo.com/group/soaplite/
      >
      > * To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      > <mailto:soaplite-unsubscribe@yahoogroups.com?subject=Unsubscribe>
      >
      > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > Service <http://docs.yahoo.com/info/terms/>.
      >
      >
    • Show all 12 messages in this topic