Presented by developerWorks, your source for great tutorials
ibm.com/developerWorks
import java.net.URL;
import localhost.axisejb.services.RemoteHelloService.Hello;
import localhost.axisejb.services.RemoteHelloService.HelloService;
public class HelloClient {
public static final String serviceClass;
public static final String url;
static {
/* Allow using other JAX RPC implementations besides Axis */
serviceClass = System.getProperty("hello.service",
"localhost.axisejb.services.RemoteHelloService.HelloServiceLocator");
/* Allow other locations for our Web service */
url = System.getProperty("hello.url",
"http://localhost:8080/axisejb/services/RemoteHelloService");
}
public static void main(String []args) throws Exception{
Hello port; //The Hello interface, in Web Service this is known as a port
HelloService service; //The service locator
/*
Dynamically load the service locator. */
service = (HelloService)
Class.forName(serviceClass).newInstance();
/*
Get the port from the service.
*
The port is the hello service. */
port = service.getRemoteHelloService(new URL(url));
/* Get the greetings from the service */
String[] greetings = port.getGreetings();
/* Print out the greetings */
for (int index=0; index < greetings.length; index++){
System.out.println(greetings[index]);
}
}
}
There is another more complicated, less performant, more portable way to create a
client. I will cover this later.
For more information on JAX RPC see
Resources
on page 31 .
If you have been following along, please create a directory called
client
and create a
file called
HelloClient.java
that implements a client based on the code listing above.
Service enable EJB SessionBeans with the IBM ETTK
Page 21 of 33






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

servlet web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved