Work with proxy servers and proxy authentication
In some cases, the Web service client must go through a proxy server to reach the PPM server. In this case, a proxy server must be specified when you establish a connection. Otherwise, a connection time out error or no connection exception will occur.
There are two solutions available (depending on whether you want all or some calls to go through the proxy):
-
Configure proxy by using client-axis2.xml.
-
Configure proxy through java code.
All Web Service Calls Go Through Proxy: Configure Proxy By Using client-axis2.xml
This configuration forces all Web service calls from the Web service toolkit to go through the proxy. This file locates in the following directory: <webservice_toolkit>/java/conf
Add following XML configuration:
<transportSender name="" class="org.apache.axis2.transport.http.CommonsHTTPTransportSend er"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</ parameter> <parameter name="PROXY" proxy_host="proxy_host_name" proxy_port="proxy_host_port" locked="true> userName:domain:password </parameter> </transportSender>
If authentication is not available, fill
"userName:domain:password" as "anonymous:anonymous:anonymous."
Some Web Service Calls Go Through Proxy: Configure Proxy By Using Java Code
If only a selected number of operations in the toolkit should go through the proxy, choose this solution.
Add the following method in the client code:
public void setProxy(Stub stub, String proxyHost, int proxyPort) { // get options Options options = stub._getServiceClient().getOptions(); if (options == null) { options = new Options(); stub._getServiceClient().setOptions(options); }
HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); proxyProperties.setProxyName(proxyHost); proxyProperties.setProxyPort(proxyPort); options.setProperty(HTTPConstants.PROXY, proxyProperties); }
Call this method before you invoke a Web service operation. For example:
DemandServiceStub stub = new DemandServiceStub(ctx, serviceURL); setProxy(stub, "proxy.example-site.com", 8888); …