Java connect to C#

On my java code, I am trying to connect to .Net C# web server and trying to get a response.
The java code (window client application) will post a file to this C# web server and get a success flag once it is completed, how do I start with the C# code as I am not a .Net programmer?
The java code:
public void transferFileToServer(String url,File localFile, String fileName) throws Exception{
		HttpURLConnection urlConn = null;
			URL  anUrl = new URL(url);
			urlConn = (HttpURLConnection)anUrl.openConnection();
			System.out.println("Swing App url connect");
			DataOutputStream ps = new DataOutputStream(urlConn.getOutputStream());
			FileInputStream fis = new FileInputStream(localFile);
			BufferedInputStream bis = new BufferedInputStream(fis);
			int len = 2048;
			byte[] bytes = new byte[len];
			int index = 0;
			while(index >= 0){
				index =,0,len);
				if(index != -1){
			BufferedInputStream dis = new BufferedInputStream(urlConn.getInputStream());
			bytes = new byte[len];
			while( > 0){
				//System.out.println("bytes read :["+new String(bytes)+"]");
		catch(Exception e){
			throw e;
			if(urlConn != null){urlConn.disconnect();}

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Refael AckermannCommented:
Simplest solution is to create and ASHX (ASPX.nET Generic HTTP Handler):

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fkchanAuthor Commented:
Do you have sample code to read the input stream, save the file to a specific location and then return a success flag?
Refael AckermannCommented:
The Context.HttpRequest.Files holds handlers to all files posted to the server as a HttpPostedFile collection.
Then you can use the HttpPostedFile.SaveAs method to save.
And then you can use Context.HttpResponse.Write to send the response.

This seems like a popular forum-thread about these kind of issues:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.