Invalid xml and 400 Bad Request


P

Peter Laan

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
 
Ad

Advertisements

T

Tiago Halm

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
 
Ad

Advertisements

P

Peter Laan

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top