471,317 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Susan - desperately seeking ...

Hi Guys (and girls),

I am in a bit of a bind. I'm looking for a simple "proof of concept" C#
app (WinForm OR console) that sends a web request to a simple PHP script
and receives BINARY data back from the PHP script. Binary data is
necessary because I want to be able to send files as well as compressed
(zipped) data.

The example PHP script can ofcourse, simply make up some dummy data and
send it to the C# app. I have tried desperately over the last few weeks
to locate such an example, but have been unsuccesful so far. I would be
most grateful for anyone who can help.

Dec 22 '05 #1
10 988
Why don't you just post the specs then someone can code it for you, zip it
and post it somewhere for you to download.
"Susan Baker" <sb****@no.spam.net> wrote in message
news:do**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
Hi Guys (and girls),

I am in a bit of a bind. I'm looking for a simple "proof of concept" C#
app (WinForm OR console) that sends a web request to a simple PHP script
and receives BINARY data back from the PHP script. Binary data is
necessary because I want to be able to send files as well as compressed
(zipped) data.

The example PHP script can ofcourse, simply make up some dummy data and
send it to the C# app. I have tried desperately over the last few weeks to
locate such an example, but have been unsuccesful so far. I would be most
grateful for anyone who can help.

Dec 22 '05 #2

Chance Hopkins wrote:
Why don't you just post the specs then someone can code it for you, zip it
and post it somewhere for you to download.


Hi Chance, Thanks for the quick response. I have sent you the specs as
well as my private email. I look forward to hearing from you.

Regards,

Sue

Dec 22 '05 #3
On Thu, 22 Dec 2005 02:58:41 +0000, Susan Baker wrote:
Hi Guys (and girls),

I am in a bit of a bind. I'm looking for a simple "proof of concept" C#
app (WinForm OR console) that sends a web request to a simple PHP script
and receives BINARY data back from the PHP script. Binary data is
necessary because I want to be able to send files as well as compressed
(zipped) data.

The example PHP script can ofcourse, simply make up some dummy data and
send it to the C# app. I have tried desperately over the last few weeks
to locate such an example, but have been unsuccesful so far. I would be
most grateful for anyone who can help.


Susan, why don't you install PEAR MAIL_Mime package and send the binary
data by email? What you want is, basically, to send data from PHP script
to an application. That is usually done through messaging/queueing
applications like MQSeries (part of WebSphere) or Tibco's RendesVous.
In the absence of such complex queueing systems, an ordinary email
might do the trick. It can be configured and played with, to make sure
that the mail ends up on the right address.
Another solution for two diverse system to communicate is to share a
database. Binary data would then be uploaded as a BLOB field and the
row pointer would be passed to the client.

--
http://www.mgogala.com

Dec 22 '05 #4
C# is not my forte but here's a very basic example:

private void button1_Click(object sender, System.EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://localhost/file.php");
request.Headers["Something"] = "Dingo";
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream hs = response.GetResponseStream();
FileStream fs = new FileStream("C:\\test.gif", FileMode.Create,
FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
BinaryReader br = new BinaryReader(hs);
Byte[] buffer;
do {
buffer = br.ReadBytes(1024);
bw.Write(buffer);
} while(buffer.Length > 0);
bw.Close();
br.Close();
}
The PHP script just dumps a gif file into the output:

<? readfile("dingo.gif"); ?>

I suggested using the HTTP headers to pass parameters in another post,
as it's fairly easy to set their values. In the PHP script, the
"Something" header will become $_SERVER['HTTP_SOMETHING']. The PHP
script can set response header using the header() function:

header("Dingo: Ate my wienerschnitzel!");

Which then is accessible through HttpWebResponse.Headers["Dingo"].

Dec 22 '05 #5
Mladen Gogala <go****@sbcglobal.net> wrote:
I am in a bit of a bind. I'm looking for a simple "proof of concept" C#
app (WinForm OR console) that sends a web request to a simple PHP script
and receives BINARY data back from the PHP script. Binary data is
necessary because I want to be able to send files as well as compressed
(zipped) data.

The example PHP script can ofcourse, simply make up some dummy data and
send it to the C# app. I have tried desperately over the last few weeks
to locate such an example, but have been unsuccesful so far. I would be
most grateful for anyone who can help.


Susan, why don't you install PEAR MAIL_Mime package and send the binary
data by email? What you want is, basically, to send data from PHP script
to an application. That is usually done through messaging/queueing
applications like MQSeries (part of WebSphere) or Tibco's RendesVous.
In the absence of such complex queueing systems, an ordinary email
might do the trick. It can be configured and played with, to make sure
that the mail ends up on the right address.
Another solution for two diverse system to communicate is to share a
database. Binary data would then be uploaded as a BLOB field and the
row pointer would be passed to the client.


That all sounds very complicated, considering that from all we've been
told, a simple web solution is a perfectly good (and *much* easier)
solution. After all, a browser requesting an image conforms exactly to
the situation Susan specified. There's no need to get message queues,
email or a database involved.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #6
Susan Baker <sb****@no.spam.net> wrote:
Hi Guys (and girls),

I am in a bit of a bind. I'm looking for a simple "proof of concept" C#
app (WinForm OR console) that sends a web request to a simple PHP script
and receives BINARY data back from the PHP script. Binary data is
necessary because I want to be able to send files as well as compressed
(zipped) data.

The example PHP script can ofcourse, simply make up some dummy data and
send it to the C# app. I have tried desperately over the last few weeks
to locate such an example, but have been unsuccesful so far. I would be
most grateful for anyone who can help.


I'd suggest splitting your problem into two parts:

1) Write a PHP script which can spit back the dummy data. (You can test
this with a web browser)

2) Write a C# client app which can download data from an arbitrary URL.
(You can test this with a web server with a dummy file on.)

If you get stuck on either part, please post on the appropriate group
with how far you've got.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #7
Following on from Jon Skeet's message. . .

I'd suggest splitting your problem into two parts:
Good idea

RFC 2616 tells you how to compose HTTP requests and interpret the HTTP
responses. (Not surprisingly, that's what PHP uses for all it's web
work.)

1) Write a PHP script which can spit back the dummy data. (You can test
this with a web browser)

2) Write a C# client app which can download data from an arbitrary URL.
(You can test this with a web server with a dummy file on.)

If you get stuck on either part, please post on the appropriate group
with how far you've got.


--
PETER FOX Not the same since the bookshop idea was shelved
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Dec 22 '05 #8
Peter Fox <pe******@eminent.demon.co.uk.not.this.bit.no.html > wrote:
I'd suggest splitting your problem into two parts:


Good idea

RFC 2616 tells you how to compose HTTP requests and interpret the HTTP
responses. (Not surprisingly, that's what PHP uses for all it's web
work.)


Fortunately, that's not really required in C# - .NET provides plenty of
infrastructure for making HTTP requests very easily.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #9
On Thu, 22 Dec 2005 06:32:16 +0000, Jon Skeet[ C# MVP] wrote:
That all sounds very complicated, considering that from all we've been
told, a simple web solution is a perfectly good (and *much* easier)
solution. After all, a browser requesting an image conforms exactly to
the situation Susan specified. There's no need to get message queues,
email or a database involved.


I don't know a squat about .NOT so I attacked the most general case.
I read some of the solutions and, at least from the PHP side, they're
trivial. Of course, I'd prefer Chung to express himself in some of humanly
readable languages instead of C#.

--
http://www.mgogala.com

Dec 22 '05 #10
Mladen Gogala <go****@sbcglobal.net> wrote:
On Thu, 22 Dec 2005 06:32:16 +0000, Jon Skeet[ C# MVP] wrote:
That all sounds very complicated, considering that from all we've been
told, a simple web solution is a perfectly good (and *much* easier)
solution. After all, a browser requesting an image conforms exactly to
the situation Susan specified. There's no need to get message queues,
email or a database involved.
I don't know a squat about .NOT so I attacked the most general case.


Fair enough. I'd suggest that those in the PHP newsgroup start at the
PHP side, and those in the C# group start on the C# side.
I read some of the solutions and, at least from the PHP side, they're
trivial.
Good - likewise on the C# side, to be honest. I suspect the problem was
that the OP wasn't sure where to start. Hopefully the suggestion of
"faking" each side while developing the other will have helped.
Of course, I'd prefer Chung to express himself in some of humanly
readable languages instead of C#.


Please, let's not start a flame war. I doubt whether you're any more
likely to persuade me that PHP is superior to C# than I am to persuade
you that C# is superior - nor am I particularly interested in trying to
do that anyway.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ben Sehara | last post: by
12 posts views Thread by David | last post: by
17 posts views Thread by EkteGjetost | last post: by
2 posts views Thread by Johnny | last post: by
10 posts views Thread by Susan Baker | last post: by
3 posts views Thread by Jia Lu | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.