Monday, September 29, 2008

Apache Axis2 Changing the Content-type of the Response

There are a couple of mechanisms that can be used to change the content-type of the response in Apache Axis2. They are,
  • Using HTTP Content Negotiation. Please refer HTTP Content Negotiation with Apache Axis2 for details.
  • Changing the content-type of the response explicitly by setting it to the response message context as follows,
  1.  MessageContext messageContext = MessageContext.getCurrentMessageContext();  
  2. OperationContext operationContext = messageContext.getOperationContext();  
  3. MessageContext outMessageContext = operationContext.getMessageContext(  
  4.            WSDL2Constants.MESSAGE_LABEL_OUT);  
  5. // responseFormat is the content type of the outgoing message  
  6. outMessageContext.setProperty(Constants.Configuration.MESSAGE_TYPE, responseFormat);  

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.