• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Help in Running code

Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am new to WS and was reading RMH.in between i decided to make a sample application for WS:

First step:
I made a class MyMath.java which gives square root of number

public class MyMath {
public int squared(int x) {
return x * x;


Next i used a plugin embedded in Eclipse IDE to generate WSDL concerning the same.


Now i used 'Generate Client' option by right clicking on WSDL
Few files got created



Then i wrote this client to access my web service

public class MyMathClient
public static void main(String args[]) throws Exception
MyMathService service = new MyMathServiceLocator();
MyMath myMath = service.getMyMath();
int x = (new Integer(args[0])).intValue();
System.out.println("The square of " +
args[0] + " is " + myMath.squared(x));

i.e. accessing squared method

-------------------------------------Now when i test this application by right clicking on WSDL file and choosing 'Test on Explorer Option' it opens test page but when i enter the square value as for example 4,it gives a fault message in response as "The AXIS engine could not find a target service to invoke! targetService is MyMath".

I have 2 questions
1.is this right way to expose your service.For instance in my case simple squared method?
2.Why i am not getting the correct square root value?Can you let me know where is the mistake?


Posts: 2968
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget about using Eclipse for now - it simply adds more problems of its own that have nothing to do with learning about web services.
As you are currently using Axis 1.x Creating Web Services with Apache Axis will get you on your way.

Preparing for web services

If you are preparing for SCDJWS 1.4 (with RMH) then you need to switch to Sun Java System Application Server PE 8.2 + JWSDP (see the bottom of SCDJWS Links) which you can then use to go through the relevant J2EE 1.4 and JWSDP tutorials.

See Which is the most suitable application server to prepare for SCDJWS?

If you are preparing for next years SCDJWS 5 you have to switch to Glassfish because JAX-WS replaces JAX-RPC (among other things). You will also need Metro to get WSIT.
[ December 05, 2008: Message edited by: Peer Reynders ]
    Bookmark Topic Watch Topic
  • New Topic