Share |
JAX-WS Client Side        
Print

JAX-WS Client Side

JAX-WS is designed in such a way that for the client the service invocation is similar to a local java method call.JAX-WS uses the SEI(Service End Point Interface). A dynamic proxy is created at runtime which handles the service invocation. JAX-WS does not uses stubs as its predecessor JAX-RPC

Let's use the web service hosted by JAX-WS Start From WSDL-doc style. Make a Java project and generate the code using wsimport utility. In Java 6+ the wsimport utility comes with the JDK. If your java is configured in the path, wsimport can be invoked at the command line.
wsimport.sh -keep -s <source folder> -d <class folder> http://localhost:8080/JAX_WS_Servlet/TemperaturConvertor?wsdl(external link)

Change the WSDL location as per your configuration. This will generate the JAXB mapping and the Service endpoint. Put the jars in Metro download (lib folder). Call the service from the main method.
TemperatureConvertorService service = new TemperatureConvertorService(); TemperatureConvertor port = service.getPort(TemperatureConvertor.class); TemperatureCelsius celsius = new TemperatureCelsius(); celsius.setReturn(100.0); TemperatureFar fahr = port.celsiusToFarenheitOp(celsius); System.out.println(fahr.getReturn());


For the client of RPC style services, again run the wsimport against RPC style wsdl. This will again generate the artifacts. Now from the main method call the service as follows:
TemperatureConvertorServiceRPC service = new TemperatureConvertorServiceRPC(); TemperatureConvertorRPC port = service.getPort(TemperatureConvertorRPC.class); Holder<Double> fahr = new Holder<Double>(); fahr.value = 212.0; port.farenheitToCelsiusOp(fahr); System.out.println(fahr.value);



Back to JAX-WS Index
Back To Java Home
Back To Home



Post new comment

Click for Help
BoldItalicUnderlineStrikethroughExternal LinkSmileys
Anti-Bot verification code: Random Image
Post new comment