Solved

SetHeaderRequest not being sent

Posted on 2014-03-06
3
356 Views
Last Modified: 2014-03-12
Dear Experts -

I'm on the last leg (i hope) of a project I have been struggling with. The Experts here have held my hand thru much of it with success - I am not experienced in this area and have run into another brick wall.

I have a hashed digital signature that needs to be sent to the customers site (which is a proxy). The code below is giving me an http.status response of 12004. I've found very little documentation on this response, except that it can be found as an http error for 'internal error'.

As an aside - he would like me to set the protocol version of my message.
In C# it's done like:        
<httpwebrequestobject>.setRequestHeader "Protocol", "System.Net.HttpVersion.Version10"

I'm not using webrequests; just MSXML2.XMLHTTP. Is there a way to set the protocol w/ this?

And the final issue - the customer is not receiving my
setheaderrequest = "hash", sdigsig.
He has sent me the headers he is receiving (below code)

Here is the code (VB6)

**** code ****
Dim objXML As New MSXML2.XMLHTTP
Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
                               
        '02.20.14 - digital sig to embed in http header...
        Dim sDigSig As String
        Dim objSig As New DigitalSignature.ComClass1
        sDigSig = objSig.GetSignature(strXML)
        Set objSig = Nothing
                
         strPost = "https://feeds.CUSTOMER.com/Feed
                        
         objXmlHttp.Open "POST", strPost, True
         objXmlHttp.setRequestHeader "hash", sDigSig
          objXmlHttp.Send (strXML)

Open in new window

**** end code

Here is what customer is receiving - i should note he is only receiving intermittent messages.

*** Customer feedback ****
Looking at the log, I d not see this message you just sent, but I do see another one sent about an hour ago.

For that message, the message body says "/Feed". It also is not finding an HTTP Header named "hash". Here are the Headers it is receiving:

http.headers={Accept-Language=en-US,
Host=feeds.CUSTOMER.com,
Accept-Encoding=gzip, deflate,
User-Agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E),
Keep-Alive=true,
Connection=true,
Accept=*/*}
*** end of customer feedback

Does anyone have ideas what is failing (error 12004) or why he isn't getting my header request "hash" "

Thank you
0
Comment
Question by:klheitz
  • 2
3 Comments
 

Accepted Solution

by:
klheitz earned 0 total points
ID: 39924050
Hi Experts;
I determined the best way to handle this issue was to move the message send code to vb.net and create a .COM exposed component.

In .net I was able to use HTTPWebRequest which gave me much more control and feedback.

.net Code to replace above is below.

 Public Sub SendMessage(strXMLIN As String, sDigSigIN As String, strURLIN As String)

        Dim req As HttpWebRequest = DirectCast(WebRequest.Create(strURLIN), HttpWebRequest)
        Dim encoding As New UTF8Encoding()
        Dim data As Byte() = encoding.GetBytes(strXMLIN)


        req = DirectCast(WebRequest.Create(strURLIN), HttpWebRequest)

        req.Method = "POST"
        req.ContentType = "application/x-www-form-urlencoded"
        req.ContentLength = data.Length
        req.ProtocolVersion = System.Net.HttpVersion.Version10
        req.Connection = False
        req.Headers.Set("hash", sDigSigIN)

        Dim strm As Stream = req.GetRequestStream()

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

        Dim response As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse)

        response.Close()

    End Sub

From w/n my VB6 project, I use the .net component this way:

            Dim objSig As New DigitalSignature.ComClass1
            sDigSig = "string hash previously created"
            strXML = "xml string previously created"

            strPost = "https://feeds.CUSTOMER.com/Feed"

            objSig.SendMessage strXML, sDigSig, strPost
            Set objSig = Nothing
0
 

Author Closing Comment

by:klheitz
ID: 39924056
Accepted my own solution.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Introduction and Prerequisites This article describes methods for detecting whether a client browser accepts and returns HTTP cookies and whether the client browser runs JavaScript.  Most client browsers will, by default, be configured to use cooki…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now