Forum Discussion

andrew_laser_1's avatar
andrew_laser_1
New Contributor
15 years ago

No mapping for the Unicode character exists in the target multi-byte code page.

Got the following exception when logging xmlhttp.responseText in the function below:

WinHttp.WinHttpRequest

 No mapping for the Unicode character exists in the target multi-byte code page.





var sInput = 

'payload=<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><GetUserSessionId xmlns="http://www.companyname.com/UR_ESB"><GuestMode>false</GuestMode><WorkId></WorkId></GetUserSessionId>';






function PostXml(sURL, sXmlInput)

{

  var xmlhttp = new ActiveXObject("WinHttp.WinHttpRequest.5.1");

  xmlhttp.open("POST", sURL, false, "", "");

  xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

  xmlhttp.send(sXmlInput);

  Log.Message(xmlhttp.responseText) //!!! Causes exception, probably because of UTF-8 encoding


}





When using JMeter for testing the same sXmlInput got no such issues. Here is the response received from JMeter:




<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Response xmlns="http://www.companyname.com/UR_ESB"><UserSessionId>G48ykMDalwKvwkgsMkQCnT5kYLVY9YNuDSkF+DdnWvUAqgfbbclskQxTZ7LS</UserSessionId><status>0</status><text>Operation completed without exception.</text></Response>





Does anybody have any idea, how to make TestComplete receive this UTF-8 response?


1 Reply

  • The reason of the problem was the typo in the charset parameter of the response header charset=utf8 should be utf-8
    Was found in the response log for xmlhttp.getAllResponseHeaders()

    The API tried to find non-existing charset 'utf8' and failed.




    After fixing the response header issue on the server side ResponseText is handled without any problems.