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 🙂

-Bugs!

Advertisements