Setting a custom HTTP header dynamically with Spring-WS client

后端 未结 7 607
我在风中等你
我在风中等你 2020-12-24 05:53

How do you set a custom HTTP header (not SOAP header) dynamically on the client side when using Spring-WS?

7条回答
  •  余生分开走
    2020-12-24 06:30

    When using spring integration 3 and spring integration-ws, the following code can be used for handling the request:

    public boolean handleRequest(MessageContext messageContext)
            throws WebServiceClientException {
        TransportContext context = TransportContextHolder.getTransportContext();
        HttpUrlConnection connection = (HttpUrlConnection) context
        .getConnection();
        connection.getConnection().addRequestProperty("HEADERNAME",
        "HEADERVALUE");
    
        return true;
    }
    

    The Interceptor can be connected to the outbound gateway in the following way:

    
    
    
    
    

提交回复
热议问题