how to make simple c# client calling web server and returning data RRS feed

  • Question

  • User300685930 posted
    I'm trying to make a very simple c# client and iis "servlet" application.  I want to send a string, process it and get a string back.  Could someone give me some pointers or send me to a site that might she me a similar example?  I'm thinking I use an ashx file on the iis side and somekind of httpclient class on the calling side but haven't figure out how.

    Thursday, June 30, 2005 1:44 PM

All replies

  • User1109032460 posted
    With this best will in the world, if that's what you want to do then use an .asmx based web method. It'll be by far the quickest way of working, and you can exploit the toolset so that it generates the client proxy for you.
    Thursday, June 30, 2005 11:29 PM
  • User300685930 posted
    I'm not wanting to use a web method because I need to implement the identical functionality on a java server.  (that is, I will need to have my .net client send this xml to a java servlet, then the java servlet will return an xml result.  I've got this working on the java side, I now just need to figure out how to do it from the .net side.
    Friday, July 1, 2005 12:09 AM
  • User1109032460 posted
    It's interesting that you don't want to use web services here, because the heterogenous environment that you're describing is almost the canonical definition of why you should be using web services. And given that the payload is XML, it just screams "web services" to me. But, if you don't want to use an .asmx, you can use a .ashx.

    Write a handler that implements IHttpHandler. Implement the ProcessRequest() method to read the HTTP payload (querystring or form variables depends on whether you're going to issue PUT or GET commands). And return a lump of XML data.

    (This, by the way, is virtually exactly what a .asmx handler does, but it adds extra value, like the test page and the wsdl generation).

    On the client side, you'll need to use the System.Net.HttpWebRequest to formulate the request. You can use the RequestStream property to set the payload before making the call to GetResponse() which actually calls the server and gets the response back (which again is pretty much what the web service proxy classes do).

    Friday, July 1, 2005 4:29 AM
  • User300685930 posted
    I'd much rather use the web service approach.  Is there a way to call a microsoft web service (.asmx) from java?  I've already done all the decoupling, and even went to the trouble of creating an xml of all primitive types.  I thought that there wasn't any interop between .net and java yet with web service but I'd be happy to be wrong on this.
    Friday, July 1, 2005 9:22 AM
  • User1181216341 posted
    I don't code in java but I came across this by seaching on Google

    Sunday, July 3, 2005 3:07 PM
  • User300685930 posted
    Thanks!  I think Axis may do the trick for me.  Didn't know about it but use Apache tomcat all the time.
    Sunday, July 3, 2005 5:30 PM