Well, you can increase the size that's read to be 1024 bytes instead of 128 bytes (note bytes, not megabytes).
You could also try taking out the secondary step of copying from variable to variable. You do this in a couple spots ($data = $file; and $data .= $fget😉.
Doubt this will help, but if you're done with $fp1, you could try closing that. If you have access to a gui on your webserver, you could install Wireshark and look at exactly what's going on with your requests and watch the call and response. Not sure how you debug your scripts, but you could always create a string to hold in memory that gets dumped to a file or to the browser, that puts in checks. Something like:
<?php
$start = $prev = microtime(1);
$debug = '[0 seconds] Page initially requested . . .';
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Starting request of anfrage.xml . . .';
$fp1 = fopen("./anfrage.xml","r");
$kennung = base64_encode("user:pass");
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Reading response of request . . .';
while(!feof($fp1))
{
$file1 = fgets($fp1, 100);
$file = $file.$file1;
}
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Done reading, moving on . . .';
$data = "";
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Starting request of SSL server . . .';
$fp = fsockopen("ssl://server.com",443,$errstr,$errno);
if(!$fp)
{
die();
}
else
{
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Hashing file for request . . .';
$file = addslashes($file);
$data = $file;
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . ($float) $diff . ' seconds] Sending headers for request . . .';
fputs($fp, "POST /webservice/XMLServlet HTTP/1.0\r\n");
fputs($fp, "Host: server.com\r\n");
fputs($fp, "Authorization: Basic ".$kennung." \r\n");
fputs($fp, "Content-length: ". strlen($data) ."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
}
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Beginning reading of response . . .';
while(!feof($fp))
{
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n\t\t".'[' . (float) $diff . ' seconds] Reading data ...';
$fget = fgets($fp, 128);
$data .= $fget;
}
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Done reading data . . .';
fclose($fp);
$xml_arr = explode("\r\n\r\n",$data);
echo $xml_arr[1];
$diff = microtime(1)-$prev;
$prev = microtime(1);
$debug .= "\n".'[' . (float) $diff . ' seconds] Done sending data to browser.';
$page = microtime(1)-$start;
$debug .= "\n".str_repeat('-', 80);
$debug .= "\n".'Page took ' . (float) $page . ' seconds to load completely.';
echo $debug;
Something like that to "benchmark" your script. Now, the microtime calls may slow it done a bit, but not much. You could take out a few and see where the major slow-down is, then focus in on that area. But like I said, I'd try changing what I suggested and see what happens.