HTTP POST acting like HTTP GET

Hi Experts;
I am attempting to post an XML to a customer's site. It's going to a dedicated URL and has a digital signature in the header.
The HTTP.send command is failing. I'm getting "The download of the specified resource has failed".

The customer informed me that by tacking the XML on to the URL, I'm performing an HTTP.Get instead of HTTP.Post. They want .POST

Here is the customer's example in c# of how he wants it done:

**** start C# example
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["HttpDestination"].ToString());
            UTF8Encoding encoding = new UTF8Encoding();
            byte[] data = encoding.GetBytes(XMLText);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = data.Length;
            req.ProtocolVersion = System.Net.HttpVersion.Version10;

            Stream strm = req.GetRequestStream();

            strm.Write(data, 0, data.Length);
            strm.Close();

            HttpWebResponse response = (HttpWebResponse)req.GetResponse();

            response.Close();

Open in new window

**** end C# example

Here is my VB6 code. It already uses .POST - and I don't know how to alter my code to make the .POST not behave like a .GET.

(in the following example strXML = <?xml version="1.0" encoding="utf-8"?><sXml><dataroot><pRec><series_of_elements></series_of_elements></pRec></dataroot></sXml>)


**** Existing VB6 code
        Set objDom = CreateObject("MSXML2.DOMDocument")
        Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
        
        'digital sig to embed in http header
        Dim sDigSig As String
        Dim objSig As New DigitalSignature.ComClass1
        'objSig.GetSignature returns a SHA1 hash of the private key and message
        sDigSig = objSig.GetSignature(strXML)
        Set objSig = Nothing
        
        objDom.loadXML strXML      
        objDom.async = True 

        strPost = "https://feeds.customer.com/Feed/ & strXML
                        
         objXmlHttp.Open "POST", strPost, False              
         objXmlHttp.setRequestHeader "hash", sDigSig
         objXmlHttp.Send objDom.xml

Open in new window

**** end VB6 code

Any advice is greatly appreciated.
Thanks
klheitz
k heitzsoftware developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

advfinanceCommented:
I believe your code is POSTing the XML to their web service but also posting it to an address containing the XML (the GET to which they are referring). I think you have an unnecessary MSXML2.DOMDocument (objDOM) and you probably need to amend strPost to not include the value of strXML (you'll know the correct URL better than I).

Try this?

Set objDom = CreateObject("MSXML2.DOMDocument")
Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
       
'digital sig to embed in http header
Dim sDigSig As String
Dim objSig As New DigitalSignature.ComClass1
'objSig.GetSignature returns a SHA1 hash of the private key and message
sDigSig = objSig.GetSignature(strXML)
Set objSig = Nothing

strPost = "https://feeds.customer.com/Feed/"
                       
objXmlHttp.Open "POST", strPost, False              
objXmlHttp.setRequestHeader "hash", sDigSig
objXmlHttp.Send strXML

Open in new window


--
Chris
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
k heitzsoftware developerAuthor Commented:
Hi Chris ~
Thank you for the example. I had to change the Send command to 'true' for the mode.

Yesterday, the customer was able to receive the messages - although some were delayed and his proxy logs indicate the delay was from my sending program.

However, this morning  he isn't able to receive any messages. I haven't made any changes and the customer is suggesting my system is 'buffering' before sending.

I've run the following checks - please see the blank header requests and error 12004.
(When I send the same message to a different customer URL, the header requests are not blank and the status = 200 (OK).)

URL: https://feeds.customer.com/Feed
Ready state before POST: 0
Ready state after POST: 1

After .Send command

Response Headers:

Status Text: Unknown
Status: 12004
Ready State after send: 4

Any ideas how I can check for 'buffered data'? or how can I clear my cache?
And do you have any ideas about the above errors?

Thanks again!
0
advfinanceCommented:
ERROR_INTERNET_INTERNAL_ERROR

    12004

    An internal error has occurred.

from http://msdn.microsoft.com/en-us/library/windows/desktop/aa385465%28v=vs.85%29.aspx

Now, does that mean an internal error on the remote server (like the HTTP Status 500 we'll all recognise), or an internal error in WinINet?

--
Chris
0
k heitzsoftware developerAuthor Commented:
Thanks for the help Chris. You solved the POST doing a GET for me :)
I'm still having issues w/ the customer not being able to receive the message and am going to open a new question. They are not getting the header "hash".
Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.