简体   繁体   中英

How to return a custom http status code for SOAP faults

I'm creating a WCF SOAP web service using BasicHttpBinding.

Unforunately, this service will be accessed through a firewall that does not allow returning http status code 500 replies from the server to the client. Any such messages from IIS are replaced with a generic error page generated by the firewall.

Therefore, my only option seems to be to return my faults disguised as http 200 messages. The consuming clients are still under development and pretty flexible, so that shouldn't be an issue. What is the best way to accomplish this? Code examples would be much appreciated.

They are doing something similar here, but my service won't be consumed by Silverlight: http://msdn.microsoft.com/es-es/library/ee844556(v=vs.95).aspx

As ErnieL wrote in his comment, http://msdn.microsoft.com/es-es/library/ee844556(v=vs.95).aspx (Creating and Handling Faults in Silverlight) turned out to be a perfectly good example for my case. I renamed the "Silverlight" parts to "Firewall" to better reflect my specific case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM