Using System Properties to Specify the Proxy Server

Invoking Web Services 6-15 Stubport._setPropertyweblogic.wsee.connection.transportinfo,info; set proxy-authentication info Stubport._setPropertyweblogic.webservice.client.proxyusername,user; Stubport._setPropertyweblogic.webservice.client.proxypassword,pass; invoke String s = port.echoHello World; System.out.printlnecho: + s; } } The sections of the preceding example to note are as follows: ■ Import the required java.net. classes: import java.net.Proxy; import java.net.InetSocketAddress; ■ Import the WebLogic HttpTransportInfo API: import weblogic.wsee.connection.transport.http.HttpTransportInfo; ■ Create a Proxy object that represents the proxy server: Proxy p = new ProxyProxy.Type.HTTP, new InetSocketAddressproxyHost, Integer.parseIntproxyPort; The proxyHost and proxyPort arguments refer to the host computer and port of the proxy server. ■ Create an HttpTransportInfo object and use the setProxy method to set the proxy server information: HttpTransportInfo info = new HttpTransportInfo; info.setProxyp; ■ Use the weblogic.wsee.connection.transportinfo WebLogic stub property to set the HttpTransportInfo object on the JAX-RPC stub: Stubport._setPropertyweblogic.wsee.connection.transportinfo,info; ■ Use weblogic.webservice.client.proxyusername and weblogic.webservice.client.proxypassword WebLogic-specific stub properties to specify the username and password of a user who is authenticated to access the proxy server: Stubport._setPropertyweblogic.webservice.client.proxyusername,user; Stubport._ setPropertyweblogic.webservice.client.proxypassword,pass; Alternatively, you can use the setProxyUsername and setProxyPassword methods of the HttpTransportInfo API to set the proxy username and password, as shown in the following example: info.setProxyUsernamejuliet.getBytes; info.setProxyPasswordsecret.getBytes;

6.5.2 Using System Properties to Specify the Proxy Server

To use system properties to specify the proxy server, write your client application in the standard way, and then specify system properties when you execute the client application. 6-16 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server You have a choice of using standard Java system properties or historical WebLogic properties. If the proxySet system property is set to false proxySet=false, proxy properties will be ignored and no proxy will be used. The following table summarizes the Java system properties. In this case, the proxySet system property must not be set. The following excerpt from an Ant build script shows an example of setting Java system properties when invoking a client application called clients.InvokeMyService : target name=run-client java fork=true classname=clients.InvokeMyService failonerror=true classpath refid=client.class.path arg line={http-endpoint} jvmarg line= -Dhttp.proxyHost={proxy-host} -Dhttp.proxyPort={proxy-port} -Dhttp.nonProxyHosts={mydomain} java target The following table summarizes the WebLogic system properties. In this case, the proxySet system property must be set to true. Table 6–3 Java System Properties Used to Specify Proxy Server Property Description http.proxyHost=proxyHost or https.proxyHost=proxyHost Name of the host computer on which the proxy server is running. Use https.proxyHost for HTTP over SSL. http.proxyPort=proxyPort or https.proxy.Port=proxyPort Port to which the proxy server is listening. Use https.proxyPort for HTTP over SSL. http.nonProxyHosts= hostname | hostname | ... List of hosts that should be reached directly, bypassing the proxy. Separate each host name using a | character. This property applies to both HTTP and HTTPS. Table 6–4 WebLogic System Properties Used to Specify the Proxy Server Property Description proxySet=true Flag that specifies that the historical WebLogic proxy properties should be used. proxyHost=proxyHost Name of the host computer on which the proxy server is running. proxyPort=proxyPort Port to which the proxy server is listening. weblogic.webservice.client. proxyusername=username Username used to access the proxy server. weblogic.webservice.client. proxypassword=password Password used to access the proxy server. Invoking Web Services 6-17 The following excerpt from an Ant build script shows an example of setting WebLogic system properties when invoking a client application called clients.InvokeMyService : target name=run-client java fork=true classname=clients.InvokeMyService failonerror=true classpath refid=client.class.path arg line={http-endpoint} jvmarg line= -DproxySet=true -DproxyHost={proxy-host} -DproxyPort={proxy-port} -Dweblogic.webservice.client.proxyusername={proxy-username} -Dweblogic.webservice.client.proxypassword={proxy-passwd} java target

6.6 Client Considerations When Redeploying a Web Service