473,666 Members | 2,237 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.Xml Exception' occurred in
System.Xml.dll
A first chance exception of type 'System.Invalid OperationExcept ion'
occurred in System.Xml.dll
A first chance exception of type
'System.Web.Ser vices.Protocols .SoapException' occurred in
System.Web.Serv ices.dll

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

"Miha V" <mi***********@ gmail.comwrote in message
news:a2******** *************** ***********@c65 g2000hsa.google groups.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.c omwrote:
"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******** *************** ***********@34g 2000hsh.googleg roups.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.c omwrote:
"Miha V" <miha.valen...@ gmail.comwrote in message

news:d7******** *************** ***********@34g 2000hsh.googleg roups.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
30513
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 (connected/disconnected), system call returns 0. Can someone please show what I am doing wrong? How to check the actual result of the ping status using C++ on Redhat linux ? Thanks in advance.
13
4623
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, status is "-1". Im guessing it has something to do with the way iplanet is invoking php, or how php was compiled. Oddly enough I have the same setup running on windows with php 4&5 and it always returns "0". Lucky for me I suppose... Anyone know...
18
3126
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 how global variables and function returns work... For example, I have a global array "char datestring;" which is defined in the function speakdate. speakdate just converts a set of integers (date variables) to a string.
4
2748
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 = get_network_info (strIpAddress, &strHostname, &nPortNumber) where this fictitious function returns a status, but also returns modified values for a hostname and a port number. In Python, there does not seem to be an easy way to have functions return...
0
4733
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 the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.
1
3963
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" defaultRedirect="/_err/generic.aspx"> <error statusCode="404" redirect="/_err/not-found.aspx" /> </customErrors> My custom error page "not-found.aspx" returns "HTTP Status Code: 404
13
3241
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 in procedures via a log in table within the database. This works fine. I have now expanded this table to include further data about the authorised user – Power User, Team Leader, & Facilitator. Depending on the user’s status as to which one of...
13
3258
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, _HEAPEMPTY, and _HEAPCORRUPT , is there something similar to this in standard C.????
7
2654
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 the status of various servers. If they are down, show an error. I found/modified this snippet: ---
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6191
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4193
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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 we have to send another system
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.