Posts

Showing posts from 2017

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