Jai’s Weblog – Tech, Security & Fun…

Tech, Security & Fun…

  • Jaibeer Malik

    Jaibeer Malik
  • View Jaibeer Malik's profile on LinkedIn
  • Subscribe

  • Feedburner

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 31 other followers

  • Archives

  • Categories

  • Stats

    • 401,931
  • Live Traffic

Archive for the ‘Tips&Tricks’ Category

Tips&Tricks: How to set web service url end point

Posted by Jai on October 11, 2013


A quick tip to change the url end point for a webservice. Keep the web service end point as configurable to be able to use it under different test/demo/live environments.

WebClientTestService service = new WebClientTestService() ;
String serviceEndPoint = "http://localhost/soap/testEndPoint";
Map<String, Object> context = ((BindingProvider)service).getRequestContext();
//Set service end point
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceEndPoint);

Keep the service end point etc. configurations as system property or pick from properties file to make it configuration in the system to be able to use different test/demo/live environment without changes the client code.

Posted in Java, Tips&Tricks, Web Services | Tagged: , | 1 Comment »

Tips&Tricks: How to enable web service client to support httpsession

Posted by Jai on October 9, 2013


A quick tip to enable web service client to support httpsession while sending requests to a web service.

WebClientTestService service = new WebClientTestService() ;
Map<String, Object> context = ((BindingProvider)service).getRequestContext();
//Set service end point
context.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);

The default behavior is that the client doesn’t maintain session cookie.

Posted in Java, Tips&Tricks | Tagged: , | Leave a Comment »

Tips&Tricks: How to set web service client request timeout value

Posted by Jai on October 9, 2013


A quick tip to set the request timeout value for the web service client. As a thumb rule always make sure to set this value at service which will be used by each request.

WebClientTestService service = new WebClientTestService() ;
int connectionTimeOutInMs = 5000;
Map<String, Object> context = ((BindingProvider)service).getRequestContext();
//Set timeout params
context.put("com.sun.xml.internal.ws.connect.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.internal.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.connect.timeout", connectionTimeOutInMs);

You don’t want to keep the client request hanging until you get the response from the server. Make sure always set timeout value while sending a request to webservice server.

Posted in Java, Tips&Tricks | Tagged: , | 1 Comment »

Tips&Tricks: How to monitor and log soap messages

Posted by Jai on October 30, 2012


A quick tip to monitor and log soap messages. Most of the monitoring tools are kind of middle man to monitor the request-response between client and server. Now you can log the traffic to file and see how data is passing around.

Set the below system property,

com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true

If you are running your client from application server eg. tomcat, you can set it as CATALINA_OPTS param.
Read the rest of this entry »

Posted in Java, Tips&Tricks, Web Services | Tagged: , , , , | 2 Comments »

Tips&Tricks: How to add soap header using JAX-WS RI

Posted by Jai on October 26, 2012


This post shares the tip how to add the soap header using jax-ws. One of the quick example could be web service authentication mechanism based on session id or some unique key based on soap headers in the request.

An example of how to do it using jax-ws, add-soap-header-object-using-pure-jax-ws

If you want to use jax-ws RI, adding_soap_header and jax-ws-adding-soap-headers

Read the rest of this entry »

Posted in Java, Tips&Tricks, Web Services | Tagged: , , , | 1 Comment »

 
%d bloggers like this: