I'm having an issue with a payment gateway (Realex RealVault) and neither Realex or myself can work out what the issue is so I thought I'd put this on here to see if anyone could help shed some light on this weird issue.
Everytime I try to send to Realex on the link: https://epage.payandshop.com/epage-remote-plugins.cgi I get an error saying:
502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
I am sending my request using the following code (stripped out the debugging code I have in here to return the 502 error for brevity):
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(LinkToRealex);
req.ContentType = "text/xml";
req.Method = "POST";
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
req.Proxy = WebRequest.DefaultWebProxy;
req.Timeout = 15000;
byte[] bytes = Encoding.ASCII.GetBytes(XMLTosend);
req.ContentLength = bytes.Length;
Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp == null) return null;
StreamReader sr = new StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
I have checked IIS logs and everything looks ok there -
2011-01-06 12:44:04 W3SVC636984653 IP_Of_Server POST /RealexTest.aspx - 80 - My_IP_Address Mozilla/5.0+(Windows;+U;+Windows+NT+6.0;+en-GB;+rv:1.9.2.13)+Gecko/20101203+Firefox/3.6.13+GTB7.1+(+.NET+CLR+3.5.30729;+.NET4.0E) 200 0 0
The weird thing is that if I try to send to Realex's other payment system (it uses a different link) everything is fine (by which I mean I get a response back from their server unfortunately I can't use this service for their RealVault service). At first this lead me to believe that everything was down to the URL I was using but because I can put this URL into the browser and get a response I think the issue might be down to IIS or my code.
I'm running asp.net 3.5 code on IIS6/Win Server 05. In IIS the website has an SSL and static IP address.
I know this is a bit of a long shot but if anyone has any ideas I could try that would be greatly appreciated.
Thanks for your help, Rich