Friday, April 2, 2010

Consuming .NET webservice using Java (netbeans 6.8) in 2 mins

I'm not a very Java person, but i was tasked to assist a team of Java developers using Solaris server. (A .Net developer's nightmare) I'm a GUI person and didn't like the command line concept, well it's powerful and have very little overhead but i need time to learn before jumping into it.

I told the team that i'm a .NET person, not a java guy. They told me leave the console/terminal/ftp to them, just help them to consume a .NET web service. Good.

I asked them from the WSDL file and went to research how java can consume a web service.

Luckily, there was a lot of resource out there documenting how to consume web service in netbeans.

First, create a New Project in NetBeans, give it a meaningful name.
Second, add a file and select "Web service" tab.
third, browse the wsdl file and click "Finish".

Now NetBeans will auto generate all the dependent files.

Expand the tree under your webservices and you will be able to see the web methods with red dots.

Drag and drop them into your methods and all the objects will be automatically instantiated and invoked with default values.

Using your java DAO(Data Access Objects) or equivalent and assign them the correct values and hit then run button.

There you go, java consumption of .NET web service in under 2 mins.

2 comments:

  1. Dear Gary,
    I am VijayaRaman, I am also trying to lean java consumption of .NET web service.
    It was really nice to know about your working style.It would be highly appreciable if you could send me an example for java consumption of .NET web service with screen shots.

    My mail id : vijayaramanp@gmail.com

    Thanks in advance
    VijayaRaman

    ReplyDelete
  2. Hi VijayaRaman,

    My steps were already step-by-step, do you really require a screenshot tutorial. It's over a year ago and i removed netbeans, it's really simple to just follow the steps listed as WSDL files (http://en.wikipedia.org/wiki/Web_Services_Description_Language) are fully self-descriptive and most of the java IDEs that i know have direct support of consuming the webservice with just the wsdl alone. Try soapUI for a simple POC :)

    ReplyDelete