This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

invoking .asmx webservice in java?  RSS feed

 
selva raja
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dears big Moose,

i want to invoke .net webservice(http://www.xxxxxxx.com/Service.asmx?WSDL) in java, how can i invoke, pass parameters to get result. please help me for this problem.

Thanks,
SR
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The beauty of web services is that it doesn't matter in which language they're implemented in - the client can use whatever language is convenient. Your favorite Java SOAP stack (whichever one that may be) probably has a tool that can generate client code from a WSDL, possibly called wsdl2java or some such.
 
selva raja
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply. which tool is best create a WSDL file from java side?

Thanks,
SR
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best would likely be the one that comes with whatever SOAP stack you intend to use.
 
selva raja
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS there any example code for calling ASP.NET webservice from java side?

Thanks,
SR
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, calling a .Net WS is not different than calling any other WS - so any Java WS tutorial (of which you'll find hundreds on the web) will do.
 
bksella sella
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the ANT task to generate client specific jar file. This jar file needs to be added to CLASSPATH on the client machine and invoke the client code...



The Client code can be as follows...Check the classes present in the client jar that got generated.



- bksella
 
selva raja
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all.
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Selva,

As Lester said, you don't need to bother about where the actual webservice is running unless you have bumped into "interoperability" problems (if the webservice written is not adhering to WS Basic Profile 1.0/1.1 standards).

1. The first thing you have to do is to pick up some Webservices API framwork to generate java stubs out of WSDL for you. There are different API available (open source as well as proprietary) Axis2, XFire, IBM WSIF, JAX-WS, etc. You have to consider which web/application server (+version) as well as J2EE/JEE version you are using before picking one of these. In most of the cases Axis2 is a good choice atleast in my opinion.

2. If you use Axis2, then go through its manual to get basic ANT script to generate java stubs.

3. Once stubs are generated, you can call webservice just like any POJO class, the underlying job of (Marshalling, Serialization, Endpoint invocatio, etc.) are handled by the framework generated proxy classes.

4. If you managed to get everything working but failed in invoking webservice call successfully, there could be then interoperability issues, which can be fixed by minor changes in your WSDL, provided in the form of Java2WSDL mappings within ANT task.

5. Here is a basic ANT script, which will give you some idea on how stubs are generated from WSDL.



Hope it helps.

Cheers,
Naren
---------------------
SCJP
SCDJWS
SCWCD
---------------------




 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
If you want to keep it simple, all you need to create a web service client is in JavaSE 6, including the wsimport command line tool that will help you create client artifacts from a WSDL.
Best wishes!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!