954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Consume .NET web-service in Java

Make the necessary changes to the web-service project in the web.config file to make it accessible to the HTTP GET & POST calls.

This is a simple Java program illustrating how you can consume the .NET web-service in Java program.

import java.io.*;
import java.net.*;

public class WebService
{
public static void main(String[] args) throws Exception
{
URL webserviceURL = new URL(” http://localhost/MyServices/WebService1.asmx/Service1″);
URLConnection webserviceConnection = webserviceURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(webserviceConnection.getInputStream()));
String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}

}

In response your get the proper XML data. So, now you need to parse the XML so as to get the essential data from it. As you can see that consuming your .NET web-service in Java is not a tricky thing :)

pranava
Newbie Poster
3 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You