Using the ClientProxyFeature API to Specify the Proxy Server

6-18 Getting Started With JAX-WS Web Services for Oracle WebLogic Server

6.6.3 Client Identity Lifecycle

A client ID is registered with the Web services runtime when the first client instance port or Dispatch instance using the client ID is created. Any asynchronous response endpoint associated with the client instances is also tracked along with the registered client ID. The client ID remains registered until one of the following occurs: ■ The client ID is explicitly disposed using the dispose method on ClientIdentityFeature , as described in Table 6–2 . ■ The container for the client instances that use the client ID is deactivated for example, the host Web application or EJB is deactivated.

6.7 Using a Proxy Server When Invoking a Web Service

You can use a proxy server to proxy requests from a client application to an application server either WebLogic or non-WebLogic that hosts the invoked Web service. You typically use a proxy server when the application server is behind a firewall. You can specify the proxy server in your client application using Java system properties. There are two ways to specify the proxy server in your client application: programmatically using the WebLogic ClientProxyFeature API or using system properties.

6.7.1 Using the ClientProxyFeature API to Specify the Proxy Server

You can programmatically specify within the Java client application itself the details of the proxy server that will proxy the Web service invoke using the weblogic.wsee.jaxws.proxy.ClientProxyFeature API. For more about the ClientProxyFeature API, see the Oracle WebLogic Server API Reference. The proxy server settings defined by the ClientProxyFeature override the settings defined at the JVM-level, as described in Section 6.7.2, Using System Properties to Specify the Proxy Server . You can configure the proxy server information using the ClientProxyFeature and pass the feature as an argument when creating the Web service port, as shown in the following example. Example 6–4 Pass ClientProxyFeature as an Argument When Creating Port package examples.webservices.simple_client; import weblogic.wsee.jaxws.proxy public class Main { public static void mainString[] args { ComplexService test = new ComplexService; ClientProxyFeature cpf = new ClientProxyFeature; cpf.setProxyHostlocalhost; cpf.setProxyPort8888; cpf.setProxyUserNameproxyu; cpf.setProxyPasswordproxyp; Note: The ClientProxyFeature configures the port for WebLogic HTTP over SSL. It is recommended that you configure SSL for WebLogic Server. For more information, see Configuring SSL in Securing Oracle WebLogic Server. Invoking Web Services 6-19 ComplexPortType port = test.getComplexPortTypePortcpf; BasicStruct in = new BasicStruct; in.setIntValue999; in.setStringValueHello Struct; BasicStruct result = port.echoComplexTypein; System.out.printlnechoComplexType called. Result: + result.getIntValue + , + result.getStringValue; } } Alternatively, you can configure the proxy server information after the port is created, as shown in the following example. In this case, you execute the attachsPort method to attach the ClientProxyFeature to the existing port. Example 6–5 Configuring the ClientProxyFeature After Creating the Port package examples.webservices.simple_client; import weblogic.wsee.jaxws.proxy public class Main { public static void mainString[] args { ComplexService test = new ComplexService; ComplexPortType port = test.getComplexPortTypePort; ClientProxyFeature cpf = new ClientProxyFeature; cpf.setProxyHostlocalhost; cpf.setProxyPort8888; cpf.setProxyUserNameproxyu; cpf.setProxyPasswordproxyp; cpf.attachsPortport; BasicStruct in = new BasicStruct; in.setIntValue999; in.setStringValueHello Struct; BasicStruct result = port.echoComplexTypein; System.out.printlnechoComplexType called. Result: + result.getIntValue + , + result.getStringValue; } } If after configuring the ClientProxyFeature and attaching it to the port you want to disable the client proxy settings, you set the proxy port to a negative value. For example: Example 6–6 Disabling Client Proxy Settings . . . ClientProxyFeature cpf = new ClientProxyFeature; cpf.setProxyPort-1;\ cpf.attachsPortport; . . .

6.7.2 Using System Properties to Specify the Proxy Server