POSTing an XML string

This is a discussion on POSTing an XML string within the Windows Programming forums, part of the Platform Specific Boards category; I need to POST a normal-everyday XML data string to a website. I FAIL when I POST with WinInet using: ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    93

    POSTing an XML string

    I need to POST a normal-everyday XML data string to a website.

    I FAIL when I POST with WinInet using:
    Code:
    string Headers="Content-Type: application/xml";
    string POSTdata="<?xml version=\"1.0\" encoding=\"utf-8\"?><note><to>Webserver</to><from>Me</from><re>My XML data</re></note>";
    HttpSendRequest(hReq, Headers.c_str(), (DWORD)-1, (LPVOID)POSTdata.c_str(), strlen(POSTdata.c_str()))
    I SUCCEED when I POST with IXMLHTTPRequest using:
    Code:
    http->setRequestHeader("Content-Type", "application/xml");
    http->send(POSTdata.c_str());
    I read that IXMLHTTPRequest encodes the XML to UTF-8:
    send Method (IXMLHTTPRequest)
    If the input type is an XML DOM object, the response is encoded according to the encoding attribute on the <? declaration in the document. If there is no XML declaration or encoding attribute, UTF-8 is assumed.
    But, I am not sure if WinInet can even encode to UTF-8:
    Issue in sending HTTP Request with UTF-8 URI using WinINet
    It would be very helpful if I can get any documentation stating that Windows APIs don't support UTF-8.
    For me though, here is why I am confused:
    UTF-8 - Wikipedia, the free encyclopedia
    The first 128 characters of Unicode, which correspond one-to-one with ASCII, are encoded using a single octet with the same binary value as ASCII, making valid ASCII text valid UTF-8-encoded Unicode as well.
    So, what is the difference?
    Byte versus Byte, character versus character.
    Shouldn't my XML string be the same in UTF-8 versus the original C++ string?

    If the answer is: "Yes, they should be the same" - then, why does WinInet FAIL?
    If the answer is: "No, they are actually different" - then, what does my XML look like in UTF-8?

    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    93
    Note:
    WinInet doesn't FAIL in making the POST.
    It's just that the website rejects the POST as being incorrect data.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Wireshark Go deep.
    Then you can see what the resulting messages are "on the wire", and compare the "good" with the "bad".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    93
    Unfortunately, the website that I am POSTing to is HTTPS.

    But that does give me an idea...
    Maybe I can POST to a friend's website and see the data that way.

    Thank-you for spurring my mind.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. posting msg as first in queue?
    By robig2 in forum Windows Programming
    Replies: 11
    Last Post: 01-15-2008, 10:28 AM
  2. question about posting
    By snaidis in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 11-18-2005, 09:29 AM
  3. Posting & You
    By DeepFyre in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 01-30-2005, 12:47 AM
  4. The Art of Zen Posting
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 82
    Last Post: 10-02-2002, 06:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21