Posts

JAX-WS Attachment with MTOM

Creating sample JAX-WS service using Message Transmission Optimization Mechanism (MTOM) to send attachment.  In SOAP world, request and response are transmitted via XML format only. When sending/receiving binary data/ file (byte[]), it will be converted to XML base 64 which will increase request / response size by 33%. To avoid this, file can be send via MTOM or XML binary Optimized packaging (XOP). This will send file as attachment without any conversation and hence size of request / response will be more or less same. Let us create exam using MTOM. In this post, we are creating Profile Web Service. Profile contains - name, address and display image. There  are 2 operations:- Create Profile Get Profile  Profile Service:-  Profile Client:-  Create new java project, create client using wsimport and add generated files in project. Below is Profile client example: Create Profile Request/Response:- Get Profile Request/Response:- Cheers..!!!

JAX-WS - SOAP Handlers

What is SOAP Handlers ? SOAP Handlers are interceptor to do additional processing of incoming and outgoing message at Client as well as Server level. For example, to check properties in handler, to audit req/response or to do any filtering. SOAP message contains three parts as below:- SOAP Header [Optional] SOAP Body Attachments [Optional] JAX-WS 2.0 defines 2 types of Handlers - Logical and Message Handler. Logical Handlers operates on message context properties and message payload only. Logical handlers are handlers that implements - javax.xml.ws.handler.LogicalHandler Message Handlers operates all parts of SOAP, i.e. SOAP Header, Body and attachments. it implements - javax.xml.ws.handler.soap.SOAPHandler There are three methods of handlers as follows:- handleMessage() - This method is called for both incoming and outgoing message for any additional processing handleFault() - This handles any fault generated by service implementation or exception generated f

WSDL Elements

Image
What is WSDL ? WSDL stands for W eb S ervice D escriptor L anguage. WSDL describes SOAP Web Service, i.e. what are input, output, SOAP service protocol etc. It is XML Document. WSDL Elements Definitions: WSDL starts with definitions root tag, it contains type , message , portType , binding and service. Definitions tag contains various attributes, which contains name (optional) - Web Service Name, targetNamespace is logical namespace information about service, xmlns ,  xmlns:soap & xmlns:xsd - standard namespace definition for describing SOAP webservice. type: contains data definition of basic to complex elements. This also includes reference external XSD message: This is abstract definition of types which are communicated as a part of web service request / response portType: This contains all operations available in web service with reference to all message binding: This contains protocol on which  web service is operating, i.e. HTTP(s), SMTP etc. with refer

Create BeanShell Script to Make Database call

BeanShell Script BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript. Following script make database connection and every iteration it takes 50 records from database and populate them in hashmap. This has been created to use with jmeter using beanshell sampler. import com.postgresql.jdbc.Driver; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.HashMap; import java.util.Map; System.out.println("Postgres Connect Example."); Connection conn = null; Statement stmt = null; ResultSet rs = null; String url = "jdbc:postgresql://192.168.3.99:5432/"; String dbName = "DB";

SQL-Lite with Hibernate

Hello All, What is SQLlite ? In my recent project I need to use SQL lite and hibernate, But Hibernate is not providing default dialect for SQLlite, so one need to write. SQL Lite Dialect. Enjoy.

All Java Version with Code names

Code Names Let us write down all java versions, its code name and release date Java 8: Spider - 18th March, 2014 Java 7: Dolphin - 28th July, 2011 Java 6: Mustang - 11th December, 2006 Java 5.0 (1.5): - Tiger - 30th September, 2004 J2SE 1.4: Merlin - 6th February, 2002 J2SE 1.3: Ketrel - 8th May, 2000  J2SE 1.2: Playground - 8th December, 1998 J2SE 1.1: 19 February 1997 JDK 1.0: Oak - 23 January 1996 Happy Reading...!!! Ref:Wikipedia

Connection Pooling

Image
Connection pooling, but what it is and what it do ? It is set of database connections that can be used in future.  This connection can be used across many sessions, once execution completes, it returns connection to connection pool.   Source: docs.oracle.com It will boost performance, because creating connection for every-user and action it will degrade performance, So how can we add connection pooling in java. Hibernate configuration using c3p0 hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost/connectionpool hibernate.connection.username=root hibernate.connection.password=<password> hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect hibernate.show_sql=false hibernate.c3p0.max_size=1 hibernate.c3p0.min_size=0 hibernate.c3p0.timeout=5000 hibernate.c3p0.max_statements=100 hibernate.c3p0.idle_test_period=300 hibernate.c3p0.acquire_increment=2 For more information, che