ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import java.net.URL;
import localhost.hrsys.services.HRService.HRSystem;
import bean.*;
public class Client {
public static void main(String[] args) throws Exception {
URL urlWsdl =
new URL("http://localhost:8080/hrsys/services/HRService?wsdl");
/* These values were collected by inspecting the WSDL file */
String nameSpaceUri = "http://localhost:8080/hrsys/services/HRService";
String serviceName = "HRSystemService";
String portName = "HRService";
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service service =
serviceFactory.createService(
urlWsdl,
new QName(nameSpaceUri, serviceName));
HRSystem myProxy =
(HRSystem) service.getPort(
new QName(nameSpaceUri, portName),
HRSystem.class);
DeptValue[] values = myProxy.getDepartments();
for (int index=0; index< values.length; index++){
System.out.println(values[index].getName());
}
}
}
To find more details on JAX RPC and creating portable clients, see
Resources
on page 31
.
This client is a bit of a pain write because you have to find the namespace URI, service
name, and portName by inspecting the WSDL file. I prefer the little bit less portable,
much easier to write version of a JAX RPC client that you created before for Hello.
Page 30 of 33
Service enable EJB SessionBeans with the IBM ETTK






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