简体   繁体   中英

Connect to WCF Using Certificate Authentication in Classic ASP

I understand that Classic ASP is not a preferred language and that it should be abandoned. Those are certainly my thoughts. In any case, let's assume it's my only option.

The Problem

I have a WCF web-service written in C# hosted at some uri https://blah/blah.svc . I have been talking to it with a Classic ASP client by manually forming SOAP calls and using Server.CreateObject("Msxml2.XMLHTTP.3.0") to make requests and get responses.

Now the WCF service has been updated to use certificate authentication. I've seen clients use cert auth in PHP and.Net, but I have no idea how one would connect using Classic ASP.

Any ideas?

Example of my current Classic ASP client

Dim objXMLHTTP : set objXMLHTTP = Server.CreateObject("Msxml2.XMLHTTP.3.0")
Dim strRequest, strResult, strFunction, strURL, strNamespace

strNamespace = "http://tempuri.org/IBlah/test"
strURL = "https://blah/Blah.svc"

strFunction = "test"

strRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">" _
& "   <soapenv:Header/>" _
& "   <soapenv:Body>" _
& "      <tem:test>" _
& "         <tem:testdata>" & testdata & "</tem:testdata>" _
& "      </tem:test>" _
& "   </soapenv:Body>" _
& "</soapenv:Envelope>"

objXMLHTTP.open "post", strURL, False

objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"

objXMLHTTP.setRequestHeader "SOAPAction", strNamespace

'send the request and capture the result
Call objXMLHTTP.send(strRequest)
response = objXMLHTTP.responseText

If it is a possibility - instead of constructing this in the ASPX page use a "proxy" which is a method that you can post your request via Ajax, which in turn would communicate with downstream service and send you back the response.

In this case your proxy (application) could be an MVC app using WCF client.

Crafting encrypted SOAP messages manually is hard, specially from Ajax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM