Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: encoding="utf-8" gets suppressed on http post

From: "Anthony Jones" <Ant@------------.--->
To: NULL
Date: 8/10/2007 12:36:00 PM

<jvanderhulst@v...> wrote in message
news:1186735503.829412.75320@x......
> On a windows 2000 machine, we use Biztalk 2002 to transport XML
> messages.
>
> One of the machines that it is communicating with, is a SAP R/3
> platform. We want to use the native HTTP capability that it has, but
> that requires XML to be encoded with UTF8 and also to have that
> explicit in the XML header so it must be: <?xml version="1.0"
> encoding="UTF-8"?>
>
> Now I have tried different alternatives, but every time I had
> something that should be a working solution the encoding="UTF-8" was
> suppressed from the actual message.
>
> In the mean time I have shifted to programming it out in ASP using
> xmlHttp.send.
>
> I tried to use transform node with an XSL that explictly adds the
> desired encoding or hard inserting the text string in front of the XML
> message. I could see the mechanisms themselves working correctly with
> adding something else than UTF-8.
> But when the actual message was posted encoding of UTF-8 was
> suppressed (left out).

It's a pity you left it out cos that the most likely place things are going
wrong.

>
> I also tried this before the actual sending:
> xmlhttp.setRequestHeader "Content-Type", "text/xml"
> xmlhttp.setRequestHeader "charset", "utf-8"

Charset isn't a header, its an attribute on the content type header. Like
this:-

xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"

however it isn't necessary.

>
> but then received an internal error:
> Error Type:
> msxml3.dll (0x80004005)
> Unspecified error
> /SAPReceiveIDOC/Repost_to_SAP.asp, line 18
>
>
> Browser Type:
> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
> 1.0.3705; .NET CLR 1.1.4322)
>
> Page:
> POST 58 bytes to /SAPReceiveIDOC/Repost_to_SAP.asp
>
> POST Data:
>
> Microsoft VBScript runtime error '800a000d'
> ----------------------
> How can I get that utf-8 on the actual posted XML message to SAP ?
>

You should build your XML in a DOMDocument then pass the DOM object to the
send method of the xmlhttp object:-

Example:-

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
Dim oXMLHttp : Set oXMLHttp =
Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")

oDOM.appendChild oDOM.createProcessingInstruction("xml", "version=""1.0""
encoding=""UTF-8""")
oDOM.appendChild oDOM.createElement("root")

oXMLHttp.open "POST", "http://server/page.asp", false
oXMLHttp.send oDOM

By posting the DOM the xmlhttp object will add the correct content type
header for you.


-- 
Anthony Jones - MVP ASP/ASP.NET




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent