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:-
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..!!!
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 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..!!!
Comments
Post a Comment