Differences between revisions 1 and 2
Revision 1 as of 2005-08-04 14:31:52
Size: 1917
Editor: 69
Revision 2 as of 2009-09-20 22:47:28
Size: 1917
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Creating a client

If you know the url of a web service (possibly one of your own at, say for this example, http://localhost:8080/axis/Bing.jws), and you want to write a client to use that web service, you can have Axis generate some Java source code files for you to make your client code simpler:

java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/Bing.jws?wsdl

Whichever directory you run that WSDL2Java command in, inside it you'll now see localhost/axis/Bing_jws. Inside Bing_jws you'll find 4 autogenerated .java files. Don't touch them. They are:

  • Bing.java -- an interface that extends java.rmi.Remote and declares some instance methods, the names of which correspond to the instance methods you created in your webapps/axis/Bing.jws file.

  • BingService.java -- another interface. This one extends javax.xml.rpc.Service and declares getBingAddress(), getBing(), and getBing( java.net.URL ).

  • BingServiceLocator.java -- a class that extends org.apache.axis.client.Service and implements BingService. You instaniate this class in your client. It's your Service object; you tell it to getBing(), and it gives you a Bing object on which you may call those instance methods you wrote in your Bing.jws class. :)

  • BingSoapBindingStub -- a class that extends org.apache.axis.client.Stub and implements Bing.

Finally, to actually create your client, you'll need to create your own new class that makes use of the ones listed above. It'll probably look something like:

import localhost.axis.Bing_jws.*;
public class MyBingClient
      public static void main( String args[] ) throws Exception
            BingService service = new BingServiceLocator();
            Bing myBing = service.getBing();
            // call instance methods on myBing, ex., say, myBing.foo() 

FrontPage/Axis/WritingYourClient (last edited 2009-09-20 22:47:28 by localhost)