473,508 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IIS returns status code 200 even if XML is invalid

Hi!

We are using ASMX web service with WSE (we're using WS-Addressing) and
IIS returns HTTP status code 200 even if XML is malformed (it can
contain illegal characters in it).

The request does not get through the stack to the application, but if
I debug the application, I can see that exception is thrown somewhere
"down there".

Is there a way to prevent IIS from returning HTTP status code 200 if
the XML is not valid?

A first chance exception of type 'System.Xml.XmlException' occurred in
System.Xml.dll
A first chance exception of type 'System.InvalidOperationException'
occurred in System.Xml.dll
A first chance exception of type
'System.Web.Services.Protocols.SoapException' occurred in
System.Web.Services.dll

Thanks,
Miha.
Aug 4 '08 #1
4 3771

"Miha V" <mi***********@gmail.comwrote in message
news:a2**********************************@c65g2000 hsa.googlegroups.com...
Hi!

We are using ASMX web service with WSE (we're using WS-Addressing) and
IIS returns HTTP status code 200 even if XML is malformed (it can
contain illegal characters in it).

The request does not get through the stack to the application, but if
I debug the application, I can see that exception is thrown somewhere
"down there".

Is there a way to prevent IIS from returning HTTP status code 200 if
the XML is not valid?
That HTTP 1.1 200 OK return code means the the HTTP request/connection
between the Web client and the Web server was OK. It is not an indication
of data exchanged between the Web client and Web service is invalid or
valid in the case the XML that has been transmitted between the Web client
and Web server.

The only thing you should be concerned about is that the 200 OK was
returned, and if it's not a 200 OK return code, then take the appropriate
action to indicate that there is something wrong with the HTTP connection
between the Web client and Web server, and the connection cannot be made
established between the two.

The return code can be 200 OK and no data was transmitted period, but most
likely, you'll get some kind formatted XML return code from the Web service
to the Web client indicating the Web service had a problem in processing
data.

So it doesn't matter if the XML is valid, not valid or no XML is returned
period when HTTP 1.1 200 OK is returned.

It's up to you check for return codes and take the appropriate action, and
it's up to you to check if the XML is valid by validating the XML data
against a XML schema and taking the appropriate action if it's valid or not
valid. HTTP 1.1 200 OK has nothing to do with valid or invalid XML being
transmitted.

Aug 5 '08 #2
Mr. Arnold,

this is not completely true. ASMX requests are handled by ASP.NET
infrastructure. And ASP.NET infrastructure unwraps (processes) the
SOAP message and invokes the method on an object to handle such
requests. This object is defined in an ASMX file, and the class behind
this ASMX file handles the call.

Normally, when there is a problem with an XML being sent to the server
(ordinary web service application), ASP.NET will complain with either
400 Bad request or 500 internal server error (depending which
extensions (WSE3.0) you use).

But in this, we're getting this weird behaviour, that ASP.NET returns
success status code back to the client, even when:
* XML is badly formatted (i.e. not well formed)
* XML does not adhere to schema/DTD

The request is not being handled by the "designated method" which
should handle the request.

To illustrate:

our scenario:
client ---- malformed XML ---IIS(asmx) --return code 200

new ASP.NET asmx webservice project:
client ---- malformed XML --IIS(asmx) --return code 400 (bad
request)

When debugging our application, I can see in the debugger that there
is exception thrown (three of them actually), but it does not affect
the status code.

Also note, that there is no XML returned from the server. Just HTTP
status code 200 and then connection terminates. It is a really weird
behaviour...

Hope that helps to clarify the problem we're seeing...

Thanks,
Miha

On Aug 5, 9:48*am, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"Miha V" <miha.valen...@gmail.comwrote in message
That HTTP 1.1 200 OK return code means the the HTTP request/connection
between the Web client and the Web *server *was OK. It is not an indication
of data exchanged between the Web client and Web service *is invalid or
valid in the case the XML that has been transmitted between the Web client
and Web server.

The only thing you should be concerned about is that the 200 OK was
returned, and if it's not a 200 OK return code, then take the appropriate
action to indicate that there is something wrong with the HTTP connection
between the Web client and Web server, and the connection cannot be made
established between the two.

The return code can be 200 OK and no data was transmitted period, but most
likely, you'll get some kind *formatted XML return code from the Web service
to the Web client indicating the Web service had a problem in processing
data.

So it doesn't matter if the XML is valid, *not valid or no XML is returned
period when HTTP 1.1 200 OK is returned.

It's up to you check for return codes and take the appropriate action, and
it's up to you to check if the XML is valid by validating the XML data
against a XML schema and taking the appropriate action if it's valid or not
valid. HTTP 1.1 200 OK has nothing to do with valid or invalid XML being
transmitted.
Aug 5 '08 #3

"Miha V" <mi***********@gmail.comwrote in message
news:d7**********************************@34g2000h sh.googlegroups.com...
Mr. Arnold,

this is not completely true. ASMX requests are handled by ASP.NET
infrastructure. And ASP.NET infrastructure unwraps (processes) the
SOAP message and invokes the method on an object to handle such
requests. This object is defined in an ASMX file, and the class behind
this ASMX file handles the call.

Normally, when there is a problem with an XML being sent to the server
(ordinary web service application), ASP.NET will complain with either
400 Bad request or 500 internal server error (depending which
extensions (WSE3.0) you use).

But in this, we're getting this weird behaviour, that ASP.NET returns
success status code back to the client, even when:
* XML is badly formatted (i.e. not well formed)
* XML does not adhere to schema/DTD

The request is not being handled by the "designated method" which
should handle the request.

To illustrate:

our scenario:
client ---- malformed XML ---IIS(asmx) --return code 200

new ASP.NET asmx webservice project:
client ---- malformed XML --IIS(asmx) --return code 400 (bad
request)

----------------------------------------------------------------------------------------
Well, if the client is sending the XML, then it should be able to vaildate
the XML before it's sent, based on a schema it has for the XML on their end.
I don't see that as an impossible task on the client's part to validate the
XML againts a its known schema before it's sent.

The second thing is something can be done on the client's side to correct
the XML that has bad characters in it. I had a situation where a 3rd party
Web service was sending bad XML to the client that had bad characters in it.
I had to scan all XML coming back from the Web service looking for the bad
characters and replace them with the characters to make the XML valid and
validate it against the known schema. I don't see that as an impossible task
on the client's side either. Maybe, you come up with the routine that is
implemented in the client code.

I don't know your total situation is in making the client send only valid
XML, but that's where I think you need to address the issue.

What you're talking about trying to override on an exception returned in the
ASMX code and controlling/overriding the HTTP status code that's retuned
from IIS may not be a viable solution.

Aug 5 '08 #4
Arnold, I certainly agree that the problem is on the client side.
Client MUST not send malformed XML. But, since client is out of our
control, this is how it is.

Anyhow, I have found the solution, or better, found what was causing
this behaviour. When I was inspecting the server-side generated proxy,
I noticed the option OneWay = true.

When the contract says OneWay = true, ASP.NET (WSE3.0 actually)
infrastructure will return status code 200 even if XML file is
invalid. Because it is one way, and the sender "does not care".
Whether this is the right thing to do or not is another question, but
that's how it works.

Thanks for your input,
Miha.

On Aug 5, 2:30*pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"Miha V" <miha.valen...@gmail.comwrote in message

news:d7**********************************@34g2000h sh.googlegroups.com...
Mr. Arnold,

this is not completely true. ASMX requests are handled by ASP.NET
infrastructure. And ASP.NET infrastructure unwraps (processes) the
SOAP message and invokes the method on an object to handle such
requests. This object is defined in an ASMX file, and the class behind
this ASMX file handles the call.

Normally, when there is a problem with an XML being sent to the server
(ordinary web service application), ASP.NET will complain with either
400 Bad request or 500 internal server error (depending which
extensions (WSE3.0) you use).

But in this, we're getting this weird behaviour, that ASP.NET returns
success status code back to the client, even when:
* XML is badly formatted (i.e. not well formed)
* XML does not adhere to schema/DTD

The request is not being handled by the "designated method" which
should handle the request.

To illustrate:

our scenario:
client ---- malformed XML ---IIS(asmx) --return code 200

new ASP.NET asmx webservice project:
client ---- malformed XML --IIS(asmx) --return code 400 (bad
request)

----------------------------------------------------------------------------------------
Well, if the client is sending the XML, then it should be able to vaildate
the XML before it's sent, based on a schema it has for the XML on their end.
I don't see that as an impossible task on the client's part to validate the
XML againts a its known schema before it's sent.

The second thing is something can be done on the client's side to correct
the XML that has bad characters in it. I had a situation where a 3rd party
Web service was sending bad XML to the client that had bad characters in it.
I had to scan all XML coming back from the Web service looking for the bad
characters and replace them with the characters to make the XML valid and
validate it against the known schema. I don't see that as an impossible task
on the client's side either. Maybe, you come up with the routine that is
implemented in the client code.

I don't know your total situation is in making the client send only valid
XML, but that's where I think you need to address the issue.

What you're talking about trying to override on an exception returned in the
ASMX code and controlling/overriding the HTTP status code that's retuned
from IIS may not be a viable solution.
Aug 5 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
30473
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
13
4604
by: inetquestion | last post by:
I've narrowed the code to a problem with php/iplanet on linux. When I run the following code from the command line "$status" comes back as "0" as it should. However when I hit it with a browser,...
18
3105
by: ben.carbery | last post by:
Hi, I have just written a simple program to get me started in C that calculates the number of days since your birthdate. One thing that confuses me about the program (even though it works) is...
4
2743
by: Michael Yanowitz | last post by:
I am still new to Python but have used it for the last 2+ months. One thing I'm still not used to is that functions parameters can't change as expected. For example in C, I can have status =...
0
4695
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
1
3953
by: Vlad | last post by:
Hello everybody, I have a problem with custom error page. I' using a redirection in a web.config file to a custom error page: <customErrors mode="RemoteOnly"...
13
3221
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
13
3242
by: aarklon | last post by:
Hi all, Is there a possible way to check the status of heap in ANSI-C or standard C....???? if my memory is correct in the old turbo c++ 3.0 compiler there were some macros by name _HEAPOK,...
7
2649
by: darrel | last post by:
I swear I've read you can do this somewhere before, but don't recall where or what it'd even be called to do the correct googling. What I've been asked to do is make a 'dashboard' app that checks...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.