How To Get MessageContext In Service Implementation Class In JAX-WS

MessageContext is used to get almost all type of info associated with current SOAP request. In JAX-WS, this how you can get MessageContext in your service implementation class:

public class TestingService {
WebServiceContext wsc;

public String sayHi(String name) {
MessageContext mc = wsc.getMessageContext();

If you are thinking who set the WebServiceContext in our class, its runtime. Before the SOAP method is called. The runtime inject the WebServiceContext identifying by @Resource annotation. And from this WebServiceContext, we get MessageContext.


Popular posts from this blog

Task 12 - Create Java Program with MySQL Database Connectivity

Java Interfaces and Exception Handling - Practice Problem with Solution

Task 16 - Javafx Program to Create, Retrieve, Update and Delete records with Database