Posts

Showing posts with the label JAX-WS

JAX-WS Webservice Endpoint and Client

JAX-WS based Webservice and Client Design Options. JAX-WS stands for Java Api for XML Web services. JAX-WS supports both SOAP 1.1 and SOAP 1.2. The following section tries to snapshot the different ways we can use JAX-WS to write both Web Services and Clients. What is Web service Endpoint? A web service endpoint is an server side resource that can be referenced by client and to which web services messages can be addressed. Generally, web services will have endpoint and a WSDL file to share its descriptions with clients. Clients use the web service endpoint description to generate/write code that can send SOAP messages to and receive SOAP messages from the web service endpoint. In JAX-WS the endpoints are annotated with the javax.jws.WebService annotation or   javax.jws.WebServiceProvider annotation, but not both at a time. Services designe options  . JAX-WS broadly supports two Webservice  models, SEI Interface Annotated with the javax.jws.WebServic...

Publishing Web Service Quickly with Java Technology

javax.xml.ws.EndPoint can be used to publish a webservice without any Application Server or Servlet Container. It uses HTTP Server that comes with Java. The static method  publish takes the String endpoint address and web service implementor class object as parameter. public class EndpointPublish { public static void main(String[] args) { Endpoint.publish("http://localhost:8088/ws/SiddMyTestWS", new SimpleHellowServiceImpl ()); } } For example just running the above stand alone java program, we are able to publish a webservice with the address   http://localhost:8088/ws/SiddMyTestWS . Where  MyWSTest is the implemented Endpoint class. Implemented EndPoint class in JAX-WS should have the following properties The implemented class should be annotated  javax.jws.WebService or javax.jws.WebServiceProvider. The implemented class should not be final or abstract . Exposed web service method should be annotated with javax.jws.WebMethod. Web service meth...

How to take JAX-WS request and response dump

Image
It took me a while to figure out how to see the request and response along with HTTP headers for JAX-WS based clients. Definitely we can write Handler to log the request/response, but that wont generate the HTTP headers. The quickest and best way for debugging purpose is to set Http TransportPipe.dump  property. We can set the following JVM property to see the Request and Response dump while invoking a particular web service using JAX-WS. The property should be set as, -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump="true" The dump generated will be outputted to System.out, and it contains The Whole SOAP Request and Response along with HTTP headers. To set the property go to Run Configuration , select the configuration and then go to the Arguments Tab. Enter the value in the box marked as  VM Arguments . Now upon calling web service from your client though eclipse, you should be getting the reqeust and response in the console. ...

JAX-WS wsimport tool to generate artifact classes

wsimport is a tool which generates Java-WS artifacts like the service end point classes from the wsdl. This tool comes with Java and used in top down approach when we need to create artifacts from wsdl. wsimport tools comes with JDK. The following shows how to use wsimport.bat on Windows. wsimport.bat -verbose -p javaexp.ws.wsgen  -d C:\Siddhartha\dev\Projects\JavaExp\MyJWS2\src  -keep CalculatorSimpleGen.wsdl The above command will generate the followings classes along with source (since we specified the -keep option). javaexp\ws\wsgen\CalculatorWS.java javaexp\ws\wsgen\CalculatorWSImplService.java javaexp\ws\wsgen\MathOperationRQ.java javaexp\ws\wsgen\MathOperationRS.java javaexp\ws\wsgen\MetaDataInfo.java javaexp\ws\wsgen\ObjectFactory.java javaexp\ws\wsgen\package-info.java javaexp\ws\wsgen\CalculatorWS.java javaexp\ws\wsgen\CalculatorWSImplService.java javaexp\ws\wsgen\MathOperationRQ.java javaexp\ws\wsgen\MathOperationRS.java javaexp\ws\wsgen\MetaDat...