HttpWebRequest

wesoloski

Newcomer
Joined
Jun 23, 2006
Messages
1
A little about what I am trying to accomplish

I am tyring to do a HttpWebRequest to a company called Paymentech.

Here are some of there requirements:
It supports one method of communication - HTTPS
I will only be doing HTTP POST requests.
The web address are as follows.
orbitalvar1.paymentech.net/authorize on port 443
Now the XML gateway URL must be accessed using the https protocol. But
interfacing to the Orbital Gateway using SSL does not require us to have a
certificate. The Orbital Gateway uses a non-authenticated SSL session,
meaning the client is not authenticated using a digital certificate as a
component of the SSL negotiation.
The Orbital Gateway uses source IP authentication to authenticate the
request generation. This is only true for the production system, the
development system will not need this.

This is the code I have to try to send the xml:
Visual Basic:
Dim xmlDoc As New XmlDocument
xmlDoc.Load("C:\CreditCardAuth.xml")
Dim request As HttpWebRequest = 
CType(HttpWebRequest.Create("https://orbitalvar1.paymentech.net:443/authorize"), 
HttpWebRequest)
request.Method = "POST"
Dim requestData As Byte() = 
System.Text.Encoding.UTF8.GetBytes(xmlDoc.OuterXml)
request.ContentLength = xmlDoc.OuterXml.Length
Dim requestStream As Stream = request.GetRequestStream
requestStream.Write(requestData, 0, requestData.Length)
requestStream.Flush()
requestStream.Close()
Dim response As HttpWebResponse = CType(request.GetResponse, 
HttpWebResponse) Dim responseData As StreamReader = New 
StreamReader(response.GetResponseStream)
Dim sendData As Byte() = System.Text.Encoding.UTF8.GetBytes(xmlDoc.OuterXml)
I am getting this error on the requestStream
The underlying connection was closed: Unable to connect to the remote
server.
TIA,
Brett
 
Last edited by a moderator:
Your request is most likely blowing up due to the fact that there is something wrong with the SSL connection. This is usually due to the server's certificate being expired or because the domain specified in the URL does not match the one encoded into the certificate. It could also be because the server's certificate is signed by an untrusted Certificate Authority (CA). This is a common thing as a lot of people issue themselves a certificate using something like OpenSSL in order to leverage the encryption capabilities of an SSL pipe.

Regardless, if you want to ignore these type of errors, you have to implement ICertificatePolicy and bind it to your request.

Here's a simple example:

http://weblogs.asp.net/wim/archive/2004/04/02/106281.aspx
 
Back
Top