Search code examples
javahttp-headerswso2wso2-api-managerapi-manager

How to add header to the backend request using java


I'm new with WSO2,I'm trying to add header in the request to my backend, so i done to add it using the calssic method or the xml method as here so now I wanna add it using java method, could you please help me how can make it

Thanks


Solution

  • Within your class mediator, try to get transport header map from axis2 context and add the new one like this.

    Map<String, String> headers = (Map) axis2MC.getProperty(
                           org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    
    headers.put("NewHeader", "Value");