How to send client certificate along with SOAP request in Classic ASP?

Posted on 2014-10-10
Last Modified: 2016-02-16
I have a Classic ASP application and now we are including the online Payment functionality.
The Payment Provider has given us the WEB Service and also a Certificate that we need to present for authentication along with the Payment Requests we send from our application.
How do I use this certificate in Classic ASP code to send the SOAP Request using XMLServerHTTP?
Are there any better methods using Classic ASP to accomplish this.
I know it is pretty old technology, but that is what we have to live with just for this project.

Thanks in Advance.
Question by:spraocs
  • 4
  • 3
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 200 total points
ID: 40373146
I have a sample soap call below.  But when you say certificate, do you mean an ssl certificate?  or are they talking about some form of authenticating?  What gateway are you using?

function searchTransactions(SalesOrderID, clientip,hash,seed,hashtype,sourcekey,SalesOrderID )

' build the xml 

strRequest =""
strRequest =strRequest&"<?xml version=""1.0"" encoding=""UTF-8""?>"
strRequest =strRequest&"<SOAP-ENV:Envelope xmlns:SOAP-ENV="""" "
strRequest =strRequest&"xmlns:ns1=""urn:usaepay"" xmlns:xsd="""" "
strRequest =strRequest&"xmlns:xsi="""" "
strRequest =strRequest&"xmlns:SOAP-ENC="""" "
strRequest =strRequest&"SOAP-ENV:encodingStyle="""">"
strRequest =strRequest&"<SOAP-ENV:Body>"

strRequest =strRequest&"<ns1:searchTransactions> "

strRequest =strRequest&"<Token xsi:type=""ns1:ueSecurityToken"">"
strRequest =strRequest&"<ClientIP xsi:type=""xsd:string"">"& clientip &"</ClientIP>"
strRequest =strRequest&"<PinHash xsi:type=""ns1:ueHash"">"
strRequest =strRequest&"<HashValue xsi:type=""xsd:string"">"& hash &"</HashValue>"
strRequest =strRequest&"<Seed xsi:type=""xsd:string"">"& seed &"</Seed>"
strRequest =strRequest&"<Type xsi:type=""xsd:string"">"& hashtype &"</Type>"
strRequest =strRequest&"</PinHash>"
strRequest =strRequest&"<SourceKey xsi:type=""xsd:string"">"& sourcekey &"</SourceKey>"
strRequest =strRequest&"</Token>"

strRequest =strRequest&"<Search SOAP-ENC:arrayType=""ns1:SearchParam[1]"" xsi:type=""ns1:SearchParamArray""> "
strRequest =strRequest&"<item xsi:type=""ns1:SearchParam""> "
strRequest =strRequest&"<Field xsi:type=""xsd:string"">Invoice</Field> "
strRequest =strRequest&"<Type xsi:type=""xsd:string"">eq</Type> "
strRequest =strRequest&"<Value xsi:type=""xsd:string"">"&SalesOrderID&"</Value> "
strRequest =strRequest&"</item> "
strRequest =strRequest&"</Search> "
strRequest =strRequest&"<MatchAll xsi:type=""xsd:boolean"">true</MatchAll> "
strRequest =strRequest&"<Start xsi:type=""xsd:integer"">0</Start> "
strRequest =strRequest&"<Limit xsi:type=""xsd:integer"">10</Limit>" 
strRequest =strRequest&"<Sort xsi:type=""xsd:string"">created</Sort> "

strRequest =strRequest&"</ns1:searchTransactions> "

strRequest =strRequest&"</SOAP-ENV:Body> "
strRequest =strRequest&"</SOAP-ENV:Envelope>"

set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")

strURL = PostToUrl

objXMLHTTP.setTimeouts 10000, 60000 , 60000, 360000 "POST", "" & strURL & "" , False
   objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
   objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)
   strResult = objXMLHTTP.responseText

' get the response
dim getCustPayMethText
    Set objReturn = CreateObject("MSXML2.DOMDocument.3.0")
    objReturn.loadXML objXMLHTTP.responseText

' parse the response

if not objReturn.getElementsByTagName("TransactionsMatched").Item(0) is Nothing  then
	TransactionsMatched=			objReturn.getElementsByTagName("TransactionsMatched").Item(0).text
end if
if cdbl(TransactionsMatched)>0 then
for x = 0 to cint(TransactionsMatched)-1

if not objReturn.getElementsByTagName("RefNum").Item(x) is Nothing  then
	RefNum=			objReturn.getElementsByTagName("RefNum").Item(x).text
end if

if not objReturn.getElementsByTagName("Result").Item(x) is Nothing  then
	Result=			objReturn.getElementsByTagName("Result").Item(x).text
end if

if not objReturn.getElementsByTagName("ResultCode").Item(x) is Nothing  then
	ResultCode=			objReturn.getElementsByTagName("ResultCode").Item(x).text
end if

if not objReturn.getElementsByTagName("CardNumber").Item(x) is Nothing  then
	CardNumber=			objReturn.getElementsByTagName("CardNumber").Item(x).text
end if

if not objReturn.getElementsByTagName("TransactionType").Item(x) is Nothing  then
	TransactionType=			objReturn.getElementsByTagName("TransactionType").Item(x).text
end if


end Function

Open in new window

LVL 32

Accepted Solution

Big Monty earned 300 total points
ID: 40373151
to set up a SOAP object,, first create a xmlHTTP object like so:

set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")

Open in new window

to set your certificate, you need to use the setOption method:


Open in new window

next, you need to make the call to the URL: "post", ""

Open in new window

once completed, send over your request:

dim msg : msg = "your request data goes here"
Call objXMLHTTP.send( msg ) 

Open in new window

and if you want to get your result, you would use the ResponseText property:

dim strResult : strResult = objXMLHTTP.responseText
Response.Write strResult

Open in new window

make sure you follow these instructions to make sure your certificate is installed properly

Use this page as a reference to all of the code above
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40373157
One thing to note, in classic asp, you have to build the xml as I did in my sample, then send that xml through the xmlhttpost.

What may be an easier route is to use php JUST FOR SENDING PAYMENT and code that on a separate page.   Many gateways  have sample code and libraries in php ready to go. Then you can just post to the php page and let it do all the work.

If you are using, they have sample code in multiple languages including classic asp

Author Comment

ID: 40375101
Thank you very much Scott Fell and Big Monty for a detailed information about this. I have earlier worked on an ASP classic website that consumed a web service. However, that was much simpler than what I am currently doing now. That was a direct web service call without a certificate.

Now I have to use a x509 certificate that I need to present while sending the SOAP requests. Thanks to Big Monty for providing the necessary code to set the certificate. And I see that both of you have pointed to the article that tells how to install the client certificate on IIS.

I used setOptions in my code and now I get the message

msxml6.dll error '80072f0c'

A certificate is required to complete client authentication

I have a few more details and questions now.

I am running the application on a Windows 2008 R2 server with IIS 7.5. The version of MSXML on the server is 6

Is the client certificate installation methods you provided applicable to the above scenario? I haev imported the certificate and it is in the 'Other People' Store. There is a 'Personal' store but I don't see a 'My' store as mentioned in some of the other examples I searched.

So, I want to start with the most appropriate thing to do here. Is it certificate installation or checking the IIS settings or something else?

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40375112
That is something different. I have only done this in PHP with a framework.  In classic asp you will need to build the xml.

I think it will be dependent in part on the api you are using.  But the sample would be
     Hg6GHjis1 ...  

Open in new window

referenced from

Author Comment

ID: 40380640
Thanks Scott, Are you saying that I need to include the certificate manually as a string like how we see it when we open it in a notepad?

And, where should I include this? Here is my sample soap request code built.

        SampleCall = "<soap:Envelope xmlns:soap="""" xmlns:samp="""">" _
        & "<soap:Header></soap:Header>" _
        & "<soap:Body>" _
        & "<samp:SampleCallRequest/>" _
        & "</soap:Body>" _
        & "</soap:Envelope>"

Author Comment

ID: 40381096
I tried to include the wsse:security as you mentioned above and also included the text of the certificate. I could be wrong here. But, that is not working.

Author Closing Comment

ID: 40581104
The issue is resolved. The problem was in the certificate installation. It worked after installing the certificate into correct certificate store.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc. Solution : Return a XML Document instea…
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

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

19 Experts available now in Live!

Get 1:1 Help Now