Search code examples
javasoapproxydispatch

Java dispatch soapmessage and proxy


I create a Java client for a webservice using this link but I need to connect to a Proxy (with user and password) before call the webservice.

At other times, I created a Proxy and open a httpconnection directly but now, I don´t know how put a Proxy with a Dispatch< SOAPMessage > that calls to "invoke(soapMsg)" method.

Any idea?

Regards.


Solution

  • I found the problem. With Dispatch only is necessary to specify:

    System.setProperty("http.proxySet", "true");
    System.setProperty("https.proxySet", "true");
    System.setProperty("http.proxyHost", proxyHost);
    System.setProperty("http.proxyPort", proxyPort);
    System.setProperty("http.proxyUser", proxyUser);
    System.setProperty("http.proxyPassword", proxyPassword);
    

    Also is necessary to specify the "Endpoint address property" that is the WS address.

    dispatcher.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://123.145.67.89:8080/name");