Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Including hashed signature in HTTP header VB6

Posted on 2014-03-03
3
Medium Priority
?
503 Views
Last Modified: 2014-03-03
Hi Experts -
I have VB6 code that I use to send an XML string to customer URL.
Recently, the customer asked us to include a digital signature in the header.
I've created the signature successfully and it is returned below as sDigSig.

I am not confident of the way I include the signature in HTTP header.
I've been all over the internet and have failed to find how this should be coded.

Please see the line below:
    objXmlHttp.setRequestHeader sDigSig, objDom.xml
below.

I think i need it to say something like:
    objXmlHttp.setRequestHeader  "Content-Type", "hash", sDigSig
but as i mentioned - i am coming up empty w/ the way I'm searching.

Also - we prefer to send this transmission asynchronously (timing is a premium).
Is this still possible to do when using .setRequestHeader ?

Thank you
klheitz

        Set objDom = CreateObject("MSXML2.DOMDocument")
        Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
       
        objDom.async = True    '07.26.13 change back to true

        '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        
       
        objDom.loadXML

            strPost = CUSTOMER_URL
                                   
            objXmlHttp.Open "POST", strPost, False
           
           
'***** // commented out
'     XMLHTTP.Open "POST", pstrURL, False ' False - syncronous mode
'
'    XMLHTTP.setRequestHeader "Content-Type", "text/xml"
'
'    XMLHTTP.setRequestHeader "X-Username", strUserName
'
'**** end comments

    objXmlHttp.setRequestHeader sDigSig, objDom.xml
                       
    objXmlHttp.Send objDom.xml
           
     strRet = objXmlHttp.responseText
0
Comment
Question by:k heitz
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
zc2 earned 2000 total points
ID: 39901137
You should ask your client what the HTTP header parameter he expects to carry the signature. Let's assume, the parameter name is "X-Signature".
Then, instead of the line
  objXmlHttp.setRequestHeader sDigSig, objDom.xml
you need
  objXmlHttp.setRequestHeader "X-Signature", sDigSig

setRequestHeader has nothing to do with async type of request. The header will be set the same way as in the sync mode, before the request is actually sent.
0
 

Author Closing Comment

by:k heitz
ID: 39901347
Thank you! Exactly what I needed.
0
 
LVL 19

Expert Comment

by:zc2
ID: 39901404
You're welcome.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

916 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