Connecting Tech Pros Worldwide Help | Site Map

Susan - desperately seeking ...

  #1  
Old December 22nd, 2005, 03:05 AM
Susan Baker
Guest
 
Posts: n/a
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.

  #2  
Old December 22nd, 2005, 03:35 AM
Chance Hopkins
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


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" <sbaker@no.spam.net> wrote in message
news:dod4p1$1qq$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...[color=blue]
> 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.
>[/color]


  #3  
Old December 22nd, 2005, 04:05 AM
Susan Baker
Guest
 
Posts: n/a

re: Susan - desperately seeking ...



Chance Hopkins wrote:[color=blue]
> 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.
>
>[/color]

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

  #4  
Old December 22nd, 2005, 04:25 AM
Mladen Gogala
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


On Thu, 22 Dec 2005 02:58:41 +0000, Susan Baker wrote:
[color=blue]
> 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.[/color]

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

  #5  
Old December 22nd, 2005, 05:55 AM
Chung Leong
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


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"].

  #6  
Old December 22nd, 2005, 06:45 AM
Jon Skeet [C# MVP]
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


Mladen Gogala <gogala@sbcglobal.net> wrote:[color=blue][color=green]
> > 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.[/color]
>
> 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.[/color]

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 - <skeet@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
  #7  
Old December 22nd, 2005, 06:45 AM
Jon Skeet [C# MVP]
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


Susan Baker <sbaker@no.spam.net> wrote:[color=blue]
> 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.[/color]

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 - <skeet@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
  #8  
Old December 22nd, 2005, 10:25 AM
Peter Fox
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


Following on from Jon Skeet's message. . .
[color=blue]
>
>I'd suggest splitting your problem into two parts:[/color]

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.)
[color=blue]
>
>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.
>[/color]

--
PETER FOX Not the same since the bookshop idea was shelved
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
  #9  
Old December 22nd, 2005, 10:55 AM
Jon Skeet [C# MVP]
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


Peter Fox <peterfox@eminent.demon.co.uk.not.this.bit.no.html > wrote:[color=blue][color=green]
> >I'd suggest splitting your problem into two parts:[/color]
>
> 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.)[/color]

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

--
Jon Skeet - <skeet@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
  #10  
Old December 22nd, 2005, 04:55 PM
Mladen Gogala
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


On Thu, 22 Dec 2005 06:32:16 +0000, Jon Skeet[ C# MVP] wrote:
[color=blue]
> 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.[/color]

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

  #11  
Old December 22nd, 2005, 05:55 PM
Jon Skeet [C# MVP]
Guest
 
Posts: n/a

re: Susan - desperately seeking ...


Mladen Gogala <gogala@sbcglobal.net> wrote:[color=blue]
> On Thu, 22 Dec 2005 06:32:16 +0000, Jon Skeet[ C# MVP] wrote:
>[color=green]
> > 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.[/color]
>
> I don't know a squat about .NOT so I attacked the most general case.[/color]

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.
[color=blue]
> I read some of the solutions and, at least from the PHP side, they're
> trivial.[/color]

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.
[color=blue]
> Of course, I'd prefer Chung to express himself in some of humanly
> readable languages instead of C#.[/color]

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 - <skeet@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
Closed Thread