Invalid xml and 400 Bad Request

Discussion in 'ASP .Net Web Services' started by Peter Laan, Mar 20, 2008.

  1. Peter Laan

    Peter Laan Guest

    Does anyone know why an ASP.NET web service considers this to be invalid
    xml:
    <endTime>9999-12-31T23:59:59.9999999</endTime>

    while this works:
    <endTime>9999-12-31T23:59:59.9999999+01:00</endTime>

    this also works:
    <endTime>2008-03-21T00:00:00</endTime>

    The first example is sent from a 3.5 winform client with DateTime.Max as
    endTime. Here's the complete xml:
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    Europe Standard
    Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    /><servicePacket /><status /><companyName
    /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    /><accountOwnerLastName
    /><accountId>-1</accountId><startTime>2008-03-19T00:00:00</startTime><endTime>9999-12-31T23:59:59.9999999</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>

    The second example is sent from a 1.1 winform client with DateTime.Max as
    endTime. Here's the complete xml:
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    Europe Standard
    Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    /><servicePacket /><status /><companyName
    /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    /><accountOwnerLastName
    /><accountId>-1</accountId><startTime>2008-03-20T00:00:00.0000000+01:00</startTime><endTime>9999-12-31T23:59:59.9999999+01:00</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>

    The third example is sent from a 3.5 winform client with a 'normal' date.
    Here's the complete xml:
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    Europe Standard
    Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    /><servicePacket /><status /><companyName
    /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    /><accountOwnerLastName
    /><accountId>-1</accountId><startTime>2008-03-20T00:00:00</startTime><endTime>2008-03-21T00:00:00</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>

    The 3.5 client is just the 1.1 client converted to 3.5.

    I get either a 400 Bad Request (when compiling the web service under 3.5)
    and a 500 internal server error with the message: 'Element' is an invalid
    node type. Line 1 position 713 (when compiled under 1.1). Anyone have any
    ideas?


    Peter
    Peter Laan, Mar 20, 2008
    #1
    1. Advertising

  2. Peter Laan

    Tiago Halm Guest

    AFAIK ASMX uses .NET serialization and DateTime format (serialization
    included probably) changed from 1.x to 2.0 (from a CLR perspective). This
    may be the cause to the issue you're seeing.

    Tiago Halm

    "Peter Laan" <> wrote in message
    news:%...
    > Does anyone know why an ASP.NET web service considers this to be invalid
    > xml:
    > <endTime>9999-12-31T23:59:59.9999999</endTime>
    >
    > while this works:
    > <endTime>9999-12-31T23:59:59.9999999+01:00</endTime>
    >
    > this also works:
    > <endTime>2008-03-21T00:00:00</endTime>
    >
    > The first example is sent from a 3.5 winform client with DateTime.Max as
    > endTime. Here's the complete xml:
    > <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    > xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    > Europe Standard
    > Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    > xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    > /><servicePacket /><status /><companyName
    > /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    > /><accountOwnerLastName
    > /><accountId>-1</accountId><startTime>2008-03-19T00:00:00</startTime><endTime>9999-12-31T23:59:59.9999999</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>
    >
    > The second example is sent from a 1.1 winform client with DateTime.Max as
    > endTime. Here's the complete xml:
    > <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    > xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    > Europe Standard
    > Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    > xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    > /><servicePacket /><status /><companyName
    > /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    > /><accountOwnerLastName
    > /><accountId>-1</accountId><startTime>2008-03-20T00:00:00.0000000+01:00</startTime><endTime>9999-12-31T23:59:59.9999999+01:00</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>
    >
    > The third example is sent from a 3.5 winform client with a 'normal' date.
    > Here's the complete xml:
    > <?xml version="1.0" encoding="utf-8"?><soap:Envelope
    > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><CesHeader
    > xmlns="http://mynta.se/ces/order/LogService"><culture>sv-SE</culture><timeZone>W.
    > Europe Standard
    > Time</timeZone></CesHeader></soap:Header><soap:Body><GetLogEntries
    > xmlns="http://mynta.se/ces/order/LogService"><type /><category /><channel
    > /><servicePacket /><status /><companyName
    > /><accountOwnerId>-1</accountOwnerId><accountOwnerFirstName
    > /><accountOwnerLastName
    > /><accountId>-1</accountId><startTime>2008-03-20T00:00:00</startTime><endTime>2008-03-21T00:00:00</endTime><bookingId>-1</bookingId></GetLogEntries></soap:Body></soap:Envelope>
    >
    > The 3.5 client is just the 1.1 client converted to 3.5.
    >
    > I get either a 400 Bad Request (when compiling the web service under 3.5)
    > and a 500 internal server error with the message: 'Element' is an invalid
    > node type. Line 1 position 713 (when compiled under 1.1). Anyone have any
    > ideas?
    >
    >
    > Peter
    >
    >
    Tiago Halm, Mar 24, 2008
    #2
    1. Advertising

  3. Peter Laan

    Peter Laan Guest

    But I get an error even if both the client and web service is running .Net
    3.5. It's easy to avoid the problem by sending some other value than
    DateTime.MaxValue though. So it's not a big problem, I'm just curious.

    Peter

    "Tiago Halm" <> wrote in message
    news:%23c%...
    > AFAIK ASMX uses .NET serialization and DateTime format (serialization
    > included probably) changed from 1.x to 2.0 (from a CLR perspective). This
    > may be the cause to the issue you're seeing.
    >
    > Tiago Halm
    >
    > "Peter Laan" <> wrote in message
    > news:%...
    >> Does anyone know why an ASP.NET web service considers this to be invalid
    >> xml:
    >> <endTime>9999-12-31T23:59:59.9999999</endTime>
    >>
    >> while this works:
    >> <endTime>9999-12-31T23:59:59.9999999+01:00</endTime>
    >>
    >> this also works:
    >> <endTime>2008-03-21T00:00:00</endTime>
    Peter Laan, Mar 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan C Douglas
    Replies:
    5
    Views:
    402
    Dan C Douglas
    Jul 22, 2003
  2. John
    Replies:
    3
    Views:
    461
  3. =?Utf-8?B?Sm9obiBIYXllcw==?=

    HTTP/1.1 400 Bad Request

    =?Utf-8?B?Sm9obiBIYXllcw==?=, Sep 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,968
    =?Utf-8?B?Sm9obiBIYXllcw==?=
    Sep 26, 2004
  4. JThomas
    Replies:
    2
    Views:
    4,476
    JThomas
    Jan 24, 2006
  5. Justin
    Replies:
    1
    Views:
    218
    A. Sinan Unur
    Mar 14, 2005
Loading...

Share This Page