HTML Response to Web Service XML Request Message

J

Julian Mensch

So, we are developing a client that consumes 3rd-party web services
using the .NET Framework in the v2.0 (Add Web Reference..., i.e., non-
WCF) method, and we've run into a thorny issue.

When there is some problem with the service host, instead of sending
back an XML response message, it will in some situations send back
an HTML error (for example, a "401 Unauthorized" page). Obviously, to
aid troubleshooting and convey meaningful errors back to the user, we
need to be able to capture this HTML so we know what went wrong.

The .NET Framework generates an error message that says "Client
found
response content type of 'text/html', but expected 'text/xml'.", but I
can't
seem to see what the 'text/html' content is. We need this for
troubleshooting
and to understand why the web service is rejecting our connection
attempts.
To doubly complicate this, the connection uses SSL, so we can't even
use
a packet sniffer to view the response -- it's all encrypted.

Can anyone tell me what API call or object property I can use to
view this
response message to a web service call from a standard VS2008-
generated
proxy class file?

-- Julian Mensch
 
G

Gregory A. Beamer

Can anyone tell me what API call or object property I can use to
view this
response message to a web service call from a standard VS2008-
generated
proxy class file?

The first thing I would do is inform the people with the service that
they are not following proper protocol, as you can package exception
messages in SOAP. ;-)

As far as capturing, you will probably end up having to hack the proxy a
bit and add error handling. This needs to be done at the level where the
message is being deserialized, as that is where you are getting the
error. At this point, the message should be "decrypted" from the SSL
connection, and the issue is with deserializing the message from the
SOAP message into objects.

NOTE: If you alter the proxy classes, you need to make sure you document
and store the source outside of the class, as well (or use source
control, which is the better option anyway). If someone regens the
proxy, they will lose the changes. I have not played with custom
proxies, so you may be able to use partial classes to avoid the
"danger" here, but I doubt it.

Peace and Grace,
Greg

--
Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

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