Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HTTP POST acting like HTTP GET

Posted on 2014-03-05
5
Medium Priority
?
869 Views
Last Modified: 2014-03-06
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
0
Comment
Question by:k heitz
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
advfinance earned 2000 total points
ID: 39906749
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
 

Author Comment

by:k heitz
ID: 39909845
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
 
LVL 5

Expert Comment

by:advfinance
ID: 39909954
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
 

Author Closing Comment

by:k heitz
ID: 39910505
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question