all groups > asp.net webservices > march 2008 >
You're in the

asp.net webservices

group:

Invalid xml and 400 Bad Request


Invalid xml and 400 Bad Request Peter Laan
3/20/2008 2:47:34 PM
asp.net webservices:
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

Re: Invalid xml and 400 Bad Request Tiago Halm
3/24/2008 8:37:39 PM
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

[quoted text, click to view]

Re: Invalid xml and 400 Bad Request Peter Laan
3/28/2008 4:58:08 PM
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

[quoted text, click to view]

AddThis Social Bookmark Button