xml per http

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jogisarge
Forum Newbie
Posts: 8
Joined: Wed Oct 31, 2007 8:57 am

xml per http

Post by jogisarge »

Hello @all,


i have to send an xml-string to a server.

we have an ibm system i with i5/os and php5 running.
the i5 is connected to the web by a 16Mbit dsl connection.

the following i tried at all

Code: Select all

 
$fp1 = fopen("./anfrage.xml","r");
$kennung = base64_encode("user:pass");
while(!feof($fp1))
{
    $file1 = fgets($fp1, 100);
    $file = $file.$file1;
}
$data = "";
$fp = fsockopen("ssl://server.com",443,$errstr,$errno);
if(!$fp)
{
    die();
}
else
{ 
    $file = addslashes($file);
    $data = $file;
    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);
}
while(!feof($fp))
{
    $fget = fgets($fp, 128);
    $data .= $fget;
}
fclose($fp);
$xml_arr = explode("\r\n\r\n",$data);
echo $xml_arr[1];
 
the response from the server comes after 14 seconds (by 1 position in xml file)
if i send a file with 5 positions the response comes after 30 seconds.

this part

Code: Select all

 
while(!feof($fp))
{
    $fget = fgets($fp, 128);
    $data .= $fget;
}
 
lasts 10 seconds.

i tried also curl, but it was also slow.
if i test the script on a webserver (in the web by a provider 1und1)then the response comes after 3-5 seconds !!!!!!!!!!!!!!1

Are there any settings i can make, to make the connection faster ?
are there alternatives to fsockopen and curl to send my xml file ?

please help me
by jo
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: xml per http

Post by vargadanis »

I think the prob is with your upload speed. Correct me if I am wrong, but 16Mb/s is your download speed. Your upload speed is what counts when sending files. Get a faster connection. It will go faster. Between 2 webhosts it must have been faster as their down/upstream is 100Mb/s.
The only way you can improve the transfer is by zipping it.
http://hu2.php.net/manual/en/function.z ... ddfile.php
And then unzipping it on the server.
Post Reply