Configuring a web services client to access resources using a web proxy
You can configure a web services client to access resources through a web proxy server.
About this task
- Configure the properties using the Java™ Virtual Machine (JVM) custom property panel in the administrative console.
- Configure the properties using the wsadmin command-line tool.
- Configure the properties with an assembly tool.
- Configure the properties programmatically using the application programming model
If you want to programmatically configure the properties using the Java API XML-based Remote Procedure Call (JAX-RPC) programming model or the Java API for XML Web Services (JAX-WS) programming model, review the JAX-RPC or JAX-WS specifications.
For a complete list of the supported standards and specifications, see the web services specifications and API documentation.
- values specified programmatically on the Call object
- values defined in the deployment descriptors in each
portQNameBinding
attribute using an assembly tool - values defined as JVM system properties
For Java API for XML Web Services (JAX-WS) web services, the HTTP transport values you specify in your policy set definitions take precedence over the values defined programmatically. Subsequently, the HTTP transport values you define programmatically take precedence over the values defined as JVM system properties. For JAX-WS applications, deployment descriptors are not supported. Use annotations to specify deployment information.
Procedure
Results
You have configured your web services client to use a Web proxy server to access resources.
You can optionally set the http.nonProxyHosts
property
to specify the host names of machines to which requests will not be
sent through the proxy server. Any requests invoked by the client
application that are sent to a host whose name is contained in this
property will not pass through the proxy server. This property applies
for both HTTP and HTTPS connections. To learn more about the http.nonProxyHosts
property
and other HTTP properties that you can configure, read about HTTP
transport custom properties for web services applications.
Example
import com.ibm.wsspi.webservices.Constants
Properties prop = new Properties();
InitialContext ctx = new InitialContext(prop);
Service service = (Service)ctx.lookup("java:comp/env/service/StockQuoteService");
QName portQname = new QName("http://httpchannel.test.wsfvt.ws.ibm.com", "StockQuoteHttp");
StockQuote sq = (StockQuote)service.getPort(portQname, StockQuote.class);
((javax.xml.rpc.Stub) sq)._setProperty(Constants.HTTP_PROXYHOST_PROPERTY, "proxyHost1.ibm.com");
((javax.xml.rpc.Stub) sq)._setProperty(Constants.HTTP_PROXYPORT_PROPERTY, "80");
//Set the https.proxyHost as a property on the RequestContext.
BindingProvider bp = (Binding Provider)port;
bp.getRequestContext().put("https.proxyHost", "proxyHost1.ibm.com");
bp.getRequestContext().put("https.proxyPort", "80");