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

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

Expand Messages
  • Byrne Reese
    I have been lagging in packaging the latest set of updates for SOAP::Lite because they are all tied into WSDL2Perl, but in the next release, the 2001 schema
    Message 1 of 12 , Apr 2, 2004
    • 0 Attachment
      I have been lagging in packaging the latest set of updates for
      SOAP::Lite because they are all tied into WSDL2Perl, but in the next
      release, the 2001 schema becomes default, and the type detector was
      upgraded to detect primitives more reliably and consistently.

      SOAP::Lite will also have integrated with it, a datetime formatter, so
      that such values can be generated more easily.

      I know that doesn't help you now, but know that the feature is coming.

      Duncan Cameron wrote:

      > At 13:52:48 on 02-04-2004 Stephane Bortzmeyer <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><num
      > >>ber
      > >xsi:type="xsd:string">NIC000000500893</number></s-gensym23></namesp
      > >>5: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 :-}
      >
      > The type is dateTime not datetime and your server needs to specify the
      > 2001 namespace not 1999, i.e.
      > xmlns:xsd="http://www.w3.org/2001/XMLSchema". The element will then be
      > deserialised simply as the string value. If you want a Perl time value
      > then you will have to do the conversion yourself.
      >
      > Regards
      > Duncan
      >
      >
      >
      > ------------------------------------------------------------------------
      > *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/>.
      >
      >
    • Steven N. Hirsch
      ... Byrne, Will the upcoming release properly handle literalxml encoding? I recently posted a workaround to enable the current version to handle this, but it
      Message 2 of 12 , Apr 2, 2004
      • 0 Attachment
        On Fri, 2 Apr 2004, Byrne Reese wrote:

        > I have been lagging in packaging the latest set of updates for
        > SOAP::Lite because they are all tied into WSDL2Perl, but in the next
        > release, the 2001 schema becomes default, and the type detector was
        > upgraded to detect primitives more reliably and consistently.

        Byrne,

        Will the upcoming release properly handle literalxml encoding? I recently
        posted a workaround to enable the current version to handle this, but it
        would be nice if that weren't required.

        Steve

        --
        ----------------------------------------------------------------
        Steven N. Hirsch tie-line: 446-6557 ext: 802-769-6557

        Staff Engineer Methodology Integration Team
        ASIC Product Development IBM Microelectronics
        ----------------------------------------------------------------
      • Stephane Bortzmeyer
        On Fri, Apr 02, 2004 at 10:19:16PM +0000, Duncan Cameron wrote ... Yes, sorry for the stupid bug. Although it is not enough to solve the
        Message 3 of 12 , Apr 3, 2004
        • 0 Attachment
          On Fri, Apr 02, 2004 at 10:19:16PM +0000,
          Duncan Cameron <dcameron@...> wrote
          a message of 57 lines which said:

          > The type is dateTime not datetime

          Yes, sorry for the stupid bug. Although it is not enough to solve the
          problem.

          > and your server needs to specify the 2001 namespace not 1999,
          > i.e. xmlns:xsd="http://www.w3.org/2001/XMLSchema".

          I do not find how to do so with SOAP::Lite (yes, my server is written
          in SOAP::Lite, too).

          > The element will then be deserialised simply as the string value. If
          > you want a Perl time value then you will have to do the conversion
          > yourself.

          No problem, HTTP::Date is here for that :-)
        • Duncan Cameron
          ... From memory, on the server side something like my $daemon = SOAP::Transport::HTTP::Daemon # etc $daemon- serializer- xmlschema( 2001 ); or
          Message 4 of 12 , Apr 3, 2004
          • 0 Attachment
            --- Stephane Bortzmeyer <bortzmeyer@...> wrote:
            >
            > > and your server needs to specify the 2001 namespace not 1999,
            > > i.e. xmlns:xsd="http://www.w3.org/2001/XMLSchema".
            >
            > I do not find how to do so with SOAP::Lite (yes, my server is written
            > in SOAP::Lite, too).

            From memory, on the server side something like

            my $daemon = SOAP::Transport::HTTP::Daemon # etc

            $daemon->serializer->xmlschema('2001');
            or
            $daemon->serializer->version('1.1');

            will cause the 2001 namespace to be used.

            Regards

            Duncan






            ___________________________________________________________
            WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes
          • Duncan Cameron
            ... Sorry to reply to my own posting but the soapversion() call doesn t work on a server in the same way as a client. Try SOAP::Lite- soapversion( 1.2 );
            Message 5 of 12 , Apr 3, 2004
            • 0 Attachment
              --- Duncan Cameron <duncan_cameron2002@...> wrote:
              > --- Stephane Bortzmeyer <bortzmeyer@...> wrote:
              > >
              > > > and your server needs to specify the 2001 namespace not 1999,
              > > > i.e. xmlns:xsd="http://www.w3.org/2001/XMLSchema".
              > >
              > > I do not find how to do so with SOAP::Lite (yes, my server is
              > written
              > > in SOAP::Lite, too).
              >
              > From memory, on the server side something like
              >
              > my $daemon = SOAP::Transport::HTTP::Daemon # etc
              >
              > $daemon->serializer->xmlschema('2001');
              > or
              > $daemon->serializer->version('1.1');
              >
              > will cause the 2001 namespace to be used.
              >
              Sorry to reply to my own posting but the soapversion() call doesn't
              work on a server in the same way as a client. Try

              SOAP::Lite->soapversion('1.2');

              /before/ creating your server daemon.

              Regards
              Duncan






              ___________________________________________________________
              WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes
            • Stephane Bortzmeyer
              On Sat, Apr 03, 2004 at 02:30:54PM +0100, Duncan Cameron wrote ... It seems completely ignored, I get the same namespace. My
              Message 6 of 12 , Apr 5, 2004
              • 0 Attachment
                On Sat, Apr 03, 2004 at 02:30:54PM +0100,
                Duncan Cameron <duncan_cameron2002@...> wrote
                a message of 37 lines which said:

                > Sorry to reply to my own posting but the soapversion() call doesn't
                > work on a server in the same way as a client. Try
                >
                > SOAP::Lite->soapversion('1.2');

                It seems completely ignored, I get the same namespace.

                My code:

                SOAP::Lite->soapversion('1.2');
                my $daemon = SOAP::Transport::HTTP::CGI
                -> dispatch_to('/local/lib/soap', '*',
                '', '');
                $daemon->handle;

                My server (Apache 1 + mod_perl):

                <Location /soap>
                SetHandler perl-script
                PerlHandler Apache::Registry
                PerlSendHeader On
                Options +ExecCGI
                DirectoryIndex dispatcher
                </Location>

                My result:

                <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
                xmlns:namesp2="http://xml.apache.org/xml-soap"
                SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
                xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:hello_dateResponse
                xmlns:namesp1="http://nic.fr/TestOnly"><s-gensym3
                xsi:type="namesp2:SOAPStruct"><Message
                xsi:type="xsd:string">World</Message><Date
                xsi:type="xsd:dateTime">2004-04-01T16:01:13</Date></s-gensym3></namesp1:hello_dateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
              • Byrne Reese
                SOAP::Lite can do the same... or as you point out: should do that same. Again, I see no impedement to getting a result from a server, and then fetching a
                Message 7 of 12 , Apr 6, 2004
                • 0 Attachment
                  SOAP::Lite can do the same... or as you point out: should do that same.
                  Again, I see no impedement to getting a result from a server, and then
                  fetching a string value from somewhere in the the result, and passing it
                  through to Date::Manip to parse the date more effectively... or hell
                  writing my own regular expression like:

                  my ($year,$month,$day,$hour,$min,$sec,$ms,$timezone) = ($date =~
                  /^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)(\.\d\d\d)?(Z|([+-]\d\d:\d\d))?$/);

                  Stephane Bortzmeyer wrote:
                  > On Tue, Apr 06, 2004 at 12:49:05PM -0700,
                  > Byrne Reese <byrne@...> wrote
                  > a message of 116 lines which said:
                  >
                  > > A recent module to CPAN seems to help address the problem:
                  > > http://search.cpan.org/~mcmahon/SOAP-DateTime-0.01/
                  >
                  > I know it and mentioned it in my first message. It only handles
                  > serialization, my problem being the deserialization.
                  >
                  > > Bottom line, SOAP::Lite doesn't (since Perl is so loosely typed) do
                  > > any type deserialization for you.
                  >
                  > I do not see the connection with my problem. Python and PHP are no
                  > more typed than Perl and both can deserialize xsd:dateTime (they just
                  > produce a string for a type they do not know, that I parse after). Why
                  > can't SOAP::Lite do the same?
                  >
                  >
                  > ------------------------------------------------------------------------
                  > *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/>.
                  >
                  >
                • Byrne Reese
                  Fair enough... here is a little bit on datetimes with SOAP::Lite... A recent module to CPAN seems to help address the problem:
                  Message 8 of 12 , Apr 6, 2004
                  • 0 Attachment
                    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/>.
                    >
                    >
                  • Stephane Bortzmeyer
                    On Tue, Apr 06, 2004 at 12:49:05PM -0700, Byrne Reese wrote ... I know it and mentioned it in my first message. It only handles
                    Message 9 of 12 , Apr 7, 2004
                    • 0 Attachment
                      On Tue, Apr 06, 2004 at 12:49:05PM -0700,
                      Byrne Reese <byrne@...> wrote
                      a message of 116 lines which said:

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

                      I know it and mentioned it in my first message. It only handles
                      serialization, my problem being the deserialization.

                      > Bottom line, SOAP::Lite doesn't (since Perl is so loosely typed) do
                      > any type deserialization for you.

                      I do not see the connection with my problem. Python and PHP are no
                      more typed than Perl and both can deserialize xsd:dateTime (they just
                      produce a string for a type they do not know, that I parse after). Why
                      can't SOAP::Lite do the same?
                    Your message has been successfully submitted and would be delivered to recipients shortly.