troubleshooting Question

Handling special characters (umlauts!) using Msxml2.ServerXMLHTTP.4.0

Avatar of camisade
camisade asked on
ASP
8 Comments1 Solution4900 ViewsLast Modified:
I'm stumped by one single thing when using Msxml2.ServerXMLHTTP.4.0. I'm sending an XML-formatted text string to a foreign server and getting a response back (using Windows 2000 Server and IIS). The problem is, when they send any special characters in the response string, my application chokes.

For example, when the response string contains an umlaut (as in the second character used in the European spelling of the city "Dusseldorf"), what I seem to be getting when I look at the response string in my browser (by displaying the XML string enclosed in <xmp> and </xmp> tags is:

<city>D?
orf</city>

Where the umlaut (and several of the following characters seem to have been garbled into a "?<CR/LF>"

Below is the code I'm using to send my XML string and receive a response (I've inserted a blank line between each line, so make wrapping issues less confusing):

Before I get to that, though, let me specify that the foreign server's spec calls for POSTing the information to them (which explains the "send" statement below. Also, they only "expect" the simplest of XML formations, and return the same, without any declaration statement. So, for example here is an XML string they're prepared to accept:
<XML>
    <REQUEST>
        <ACTION>GET_PAYMENTPRODUCTS</ACTION>
        <META>
            <MERCHANTID>1</MERCHANTID>
            <IPADDRESS>123.123.123.123</IPADDRESS>
            <VERSION>1.0</VERSION>
        </META>
    </REQUEST>
</XML>
...and their return strings are formatted in the same way (with the <XML> tag serving as the root element).

Here's my ASP code:
=====================
set xmlhttp = server.Createobject("Msxml2.ServerXMLHTTP.4.0")

xmlhttp.Open HTTP_POST, WDL_URL_PREFIX, false

mlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

xmlhttp.send "IN=" + Server.URLEncode(xmlstring)

Response.ContentType = "text/html"

GC_response = xmlhttp.responseText

Set xmlhttp = nothing

Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
                   
xmlDoc.async = False

xmlDoc.LoadXML GC_response

===========================

Here's an example of the "XML" response I'm parsing, if you need this much detail:
<XML>
    <REQUEST>
        <ACTION>GET_PAYMENTPRODUCTS</ACTION>
        <META>
            <MERCHANTID>1</MERCHANTID>
            <IPADDRESS>123.123.123.123</IPADDRESS>
            <VERSION>1.0</VERSION>
        </META>
        <RESPONSE>
            <RESULT>OK</RESULT>
            <ROW> <PAYMENTMETHODNAME>Online/Telebanking</PAYMENTMETHODNAME>
<PAYMENTPRODUCTID>548</PAYMENTPRODUCTID>
<PAYMENTPRODUCTNAME>NatWest</PAYMENTPRODUCTNAME>
<CORDERTYPE>1</ORDERTYPE>
            </ROW>
        </RESPONSE>
    </REQUEST>
</XML>

So, what do I have to do to be able to handle it gracefully when one of their child nodes contains a special character like an umlaut?

Thanks for any help you can give,

Kevin
ASKER CERTIFIED SOLUTION
YensidMod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros