WebServiceTemplate sends through its WebServiceMessageSender. Configure that sender’s HTTP client when the SOAP destination requires a forward proxy.

For Spring WS 4.1 with Apache HttpClient 5 available:

var http = org.apache.hc.client5.http.impl.classic.HttpClients.custom()
    .setProxy(new org.apache.hc.core5.http.HttpHost(
        "http", "proxy.example", 8080))
    .addRequestInterceptorFirst(
        new org.springframework.ws.transport.http
            .HttpComponents5ClientFactory.RemoveSoapHeadersInterceptor())
    .build();

var sender = new org.springframework.ws.transport.http
    .HttpComponents5MessageSender(http);
webServiceTemplate.setMessageSender(sender);

webServiceTemplate is the application’s existing template. Its SOAP service URI stays the destination; the HTTP client holds the intermediary, which may be a public candidate from the HTTP proxy list when that route is permitted.

The custom-client constructor does not add the sender’s usual header interceptor. Keep it when assembling the client: it removes SOAP-supplied transport headers that Apache’s request processing manages. A sender built through the client factory’s defaults is another construction path that retains this integration.

Add required proxy credentials and timeouts on the custom client through its own supported interfaces. The sender’s setter methods are not a substitute for configuring an already supplied client.

Retain the client for the template’s workload and close owned resources at shutdown. This example uses the HttpClient 5 sender; Spring WS examples importing org.apache.http describe another client generation.

Tënë sô zo