Page 1 of 2
Help send file
Posted: Tue Sep 12, 2006 9:58 am
by roby2411
Please help how can I send XML file to a webservice on a server listening on a port
i.e
assume that i have xml file named file.xml
and the web service url is
http://192.168.1.1:5555 where 5555 is the port i need to send for
how could i send this file.xml to the service URL
please help me i'm really getting crazy for this
thankyou
Posted: Tue Sep 12, 2006 10:54 am
by Burrito
what have you tried?
you might look into
fsockopen().
Send File
Posted: Wed Sep 13, 2006 4:20 am
by roby2411
actually I didn't try any way as this is my first time i found this problem and i'm not sure what to do
Posted: Wed Sep 13, 2006 4:47 am
by volka
How does this service expect the data to be delivered?
Send File
Posted: Wed Sep 13, 2006 4:57 am
by roby2411
It accept a valid XML file or XML data string
Posted: Wed Sep 13, 2006 5:00 am
by volka
And it does this by FTP, POST (what parameter), GET (what paraemter), PUT, smtp or bongo drums?
Posted: Wed Sep 13, 2006 5:05 am
by roby2411
It does it by HTTP POST
Posted: Wed Sep 13, 2006 5:09 am
by volka
And the parameter is? Maybe more than one?
Come on ..work with me here. You must have thought a bit about the problem, didn't you?
Posted: Wed Sep 13, 2006 5:12 am
by roby2411
Code: Select all
<?xml version="1.0"?>
<SIGNData>
<SIGNMessage>
<Submit DeliveyReport="Yes" ReadReply="No" ReplyCharging="No" Adaptation="Yes" Redistribution="No">
<ID>-1</ID>
<Type>MT_TEST</Type>
<From AddrType="AT_EMAIL" UserID="test" UserCredit="10">test</From>
<Recipients>
<To AddrType="AT_MISSDN">202</To>
</Recipients>
<Subject>PHP</Subject>
<ObjectList>
<Object>
</Object>
</ObjectList>
<SmilFrame ID="0">
<Duration>3</Duration>
</SmilFrame>
<SmilFrame ID="1">
<Duration>3</Duration>
</SmilFrame>
<ServiceCode></ServiceCode>
<LinkedID></LinkedID>
<ClassType> MM_CT_PERSONNEL</ClassType>
<Priority> MM_PT_NORMAL</Priority>
<SubmitTime>2006-07-05T12:25:14-0400</SubmitTime>
<ExpiryTime>2006-07-08T00:00:00-0400</ExpiryTime>
<DeliveryTime>2006-07-05T00:00:00-0400</DeliveryTime>
<ReplyDeadLine></ReplyDeadLine>
</Submit>
</SIGNMessage>
</SIGNData>
here is the xml i wanna send
and i wanna send it to
http://www.domainname.com:5050
Posted: Wed Sep 13, 2006 5:18 am
by volka
a common html form
Code: Select all
<form method="post" action="xyz">
<input type="text" name="textinput" />
<input type="file" name="fileinput" />
<intput type="submit" />
</form>
to a php script the transmitted data would be provided by $_POST['textinput'] or $_FILE['fileinput'].
You service probably does something similar. Therefore it's imperative to know what parameters (names) must be used.
The xml document is not of interest here.
Posted: Wed Sep 13, 2006 5:31 am
by roby2411
No no it goes like that
A form that user fill with the date input 1,2,3,4.........etc
user sumit the form
I pass the form variable to a PHP page that deal with the data and generate an XML string
and the missing step now that i wanna send this XML data string to the url on the sepecified port
Posted: Wed Sep 13, 2006 5:35 am
by volka
But the service you want to send the xml data to most probably expects a name=value pair as well.
value is your xml string. name is ...?
Posted: Wed Sep 13, 2006 5:37 am
by roby2411
But the service you want to send the xml data to most probably expects a name=value pair as well
no it just listen to the xml string and only waiting for a valid XML data type
the XML name is TESTMODE.xml
Posted: Wed Sep 13, 2006 9:52 am
by volka
Ok, if you're sure, that the request message body is nothing more than the raw xml document I have to trust you
you can try pear's http_client.
Code: Select all
<?php
require_once 'HTTP/Client.php';
$data='<?xml ... ?>';
$target = 'http://www.domainname.com:5050';
$client= new HTTP_Client;
$client->post($target, $data, true);
var_dump( $client->currentResponse() );
?>
the important thing is the third parameter set to true, telling http_client that the data already has proper encoding.
PEAR & http_client have to be installed for this to be working, see
http://pear.php.net/manual/en/package.h ... client.php
Posted: Wed Sep 13, 2006 11:21 am
by roby2411
I downloded the required file and it gives me error
Warning: require_once(HTTP/Request.php) [function.require-.....
so I downloaded Request.php and it give error again
Warning: require_once(HTTP/PEAR.php) [function.require-.....
again i downloaded the PEAR.php and it gives error
Warning: require_once(Net/Socket.php) [function.require-.....
and now i can't find this socket.php
Dear volka let me thank you a warm thankful due to your interest and i have another question that me help me solving my problem
while i'm trying the following code
Code: Select all
<?php
$fp = fsockopen("192.168.1.101", 5050, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: 192.168.1.101\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
it gives me the following error
Warning: fsockopen() [function.fsockopen]: unable to connect to 192.168.1.101:5050 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\AppServ\www\post\ex6.php on line 2
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
and i do listen to the bort with linux ethereal but i never recieve any package while listening to the port
once again i tried this code :
Code: Select all
<?php
$fp = fsockopen("udp://192.168.1.101", 5050, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fwrite($fp, "\n");
echo fread($fp, 26);
fclose($fp);
}
?>
and i found the packeage goes well and i recieve it on my linux machine
so now I can't find where is the problem
and if i'm gonna use the second code only 1 missing thing is how to transfer the sample.xml with that stream i have