fsockopen and SSL Problem
Posted: Thu Feb 01, 2007 11:52 am
I'm just trying to test one of the webservices we use at work, but I can't even set up a simple PHP script to test it 
The problem I'm having is that I can't connect to the server that is running the service to even try to post a request to it. Here's what I got:
The problem is the fsockopen itself. If I use just fsockopen("https://axis.adin.net") (no port), it goes straight to the error out line (just blank since I didn't want to know the errors), but if I put in 80 or 443 for the port, it breaks (port 80, port 443). If I try just fsockopen("axis.adin.net", 80) or 443, it "works", but no result comes back at all (port 80, port 443).
I'm not exactly sure what's going on with it. It seems to want to work when it uses the default TCP protocol, and even when I visit http://axis.adin.net, I get no response from the webserver at all, however if I visit https, it works just fine.
The problem I'm having is that I can't connect to the server that is running the service to even try to post a request to it. Here's what I got:
Code: Select all
switch($_GET['try']) {
case 1:
$fp = fsockopen("https://axis.adin.net", 80, $errno, $errstr, 30);
break;
case 2:
$fp = fsockopen("https://axis.adin.net", 443, $errno, $errstr, 30);
break;
case 3:
$fp = fsockopen("axis.adin.net", 80, $errno, $errstr, 30);
break;
case 4:
$fp = fsockopen("axis.adin.net", 443, $errno, $errstr, 30);
break;
case 5:
$fp = fsockopen("https://axis.adin.net");
break;
}
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$file = file_get_contents("myxml.xml");
$out = "POST /interfaces/loanshield.asmx/PullLoanShield HTTP/1.1\n";
$out .= "Host: axis.adin.net\n";
$out .= "Content-Type: application/x-www-form-urlencoded\n";
$out .= "Content-Length: " . strlen($file) . "\n";
$out .= "strXML=" . $file;
$result = "";
fwrite($fp, $out);
while (!feof($fp)) {
$result .= fgets($fp, 1024);
}
fclose($fp);
echo $result;
}I'm not exactly sure what's going on with it. It seems to want to work when it uses the default TCP protocol, and even when I visit http://axis.adin.net, I get no response from the webserver at all, however if I visit https, it works just fine.