Is there any way to force the JVM to use a specific source IP address when using the default, built-in java.xml.SOAPConnectionFactory? It appears the default ends up creating HttpSOAPConnection objects (sun private API), which then uses HttpURLConnection underneath the hood. I can't seem to find any system property to make HttpURLConnection use a specific source IP. There is a similar stackoverflow question, but I'm hoping someone else has more information, or a trick I can use.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Http Client from Apache Commons (http://hc.apache.org/httpcomponents-client-ga/) supports this:
"ConnRoutePNames.LOCAL_ADDRESS='http.route.local-address': defines a local address to be used by all default route planner. On machines with multiple network interfaces, this parameter can be used to select the network interface from which the connection originates. This parameter expects a value of type java.net.InetAddress. If this parameter is not set, a default local address will be used automatically."