Creating a JAX-WS Web Service Proxy in JDeveloper

You use the JDeveloper wizard to create a custom JAX-WS web service consumer.

To select JAX-WS as the standard for creating the JAX-WS based business service consumer project:

  1. In JDeveloper, right-click on the appropriate business service consumer project and select Project Properties.

    The Project Properties window for the selected published business service appears.

  2. In the left-hand side tree structure, select Libraries and Classpath.

    The Libraries and Classpath page appears on the right-hand side of the window.

  3. In the Classpath Entries area, select JAX-WS Web Services.

  4. Move the JAX-WS Web Services entry to the top of the page by clicking the Move Up button

    Clicking the Move Up button moves the entry one level at a time; you may need to click the Move Up button multiple times to move the JAX-WS Services entry to the top of the page.

  5. Click OK.

  6. On JDeveloper, save the changes that you made to the Libraries and Classpath property of the selected published business service.

To create a JAX-WS Web Service Proxy:

  1. In JDeveloper, right-click on the appropriate business service client project and select New to open the New Gallery Window.

  2. On the New Gallery window, select the All Technologies tab.

  3. In the left-hand tree structure, expand the Business Tier category and select Web Services.

  4. Select Web Service Proxy from the list of items that appears in the right-hand pane.

  5. Click OK.

    This action opens the Create Web Service Proxy Wizard.

  6. On the Welcome page click Next to open the Select Web Service Description page.

  7. On Select Web Service Description, do the following:

    • In the WSDL Document URL field, enter the WSDL URL of the targeted JAX-WS based web service.

      The WSDL URL is that of the targeted business service that is running on the JDeveloper 11g integrated WebLogic server.

    • Select the Copy WSDL Into Project option

      Note: If you are using JDeveloper 12c to create a JAX-WS based consumer web-service, a customization file must be used to prevent the WSIMPORT tool from flattening the web service input arguments.
    • Click Next to open the Specify Default Mapping Options page.

  8. On specify Default Mapping Options, do the following:

    • Enter the business service project name package in the Package Name field; for example, oracle.e1.bssv.JRH90I34.proxy

    • Enter the business service proxy type in the Root Package for Generated Types field; for example, oracle.e1.bssv.JRH90I34.proxy.types

    • Click Next to open the Port Endpoints page.

  9. On Port Endpoints, do the following:

    • Verify the system-entered endpoint URL of the targeted JAX-WS based web service.

    • Click Next to open the Asynchronous Methods page.

  10. On Asynchronous Methods, select the Don't generate any asynchronous methods option.

  11. On the Policy page, click Next to open the Defined Handlers page.

    This page is optional. In this task, a JAX-WS client is being created for the web service running locally, which does not have any security configured. However, if you are creating a JAX_WS client for a web service that is secured with an OWSM policy, select the appropriate policy from the list that appears in the Security tab.

  12. On Defined Handlers, accept the system entered information and then click Next to open the Finish page.

  13. On Finish, click the Finish button to complete the creation of the JAX-WS business service client proxy.

After the proxy is successfully generated, expand the JAX-WS business service client project in JDeveloper. A folder named Proxy contains the classes required by the proxy to invoke the target web service. This folder also contains a types folder that has all of the classes that are used by proxy to invoke the operations of the target web service.

Next step is to create the *Processor.java class to invoke the target JAX-WS web service. In the client RI JRH90I34, refer to the RI_JAXWS_ABWebServiceProcessor.java to see how the Processor class has been coded to invoke the target JAX-WS web service. The RI_JAXWS_ABWebServiceProcessor.java has been coded in such a way so that the same JAX-WS client works against a target RI_AddressBookManager JAX-WS web service running on Jdeveloper 11g's Integrated WLS, Standalone WLS or WAS.

Note the following points regarding the code in the RI_JAXWS_ABWebServiceProcessor.java class:

  • Fetch the endpoint URL of the target web service from the softcoding record.

  • If the web service is secure, also retrieve user name and password credentials from the softcoding record

  • If the target web service is secured with WS-Security and it requires username and password credentials to be passed to the SOAP header from the client, do the following

    1. Create a class that implements the SOAPHandler interface to create the WS-Security Header with the username and password credentials retrieved from the softcoding record.

    2. Create a class that implements the HandlerResolver interface, which ensures that the class that implements the SOAP Handler interface is called.

    3. Create an instance of the SOAPHandler class in the client Processor class, and set the username and password credentials retrieved from the softcoding record in this instance.

    4. Create an instance of the HandlerResolver class in the client Processor class, add the instance of the SOAPHandler class to this instance.

    5. Add the instance of the HandlerResolver class to the instance of the target web service.

    6. Set the endpoint URL, user name, and password credentials retrieved from the softcoding record in the RequestContext object of the target web service.

Note: In the RI-JAXWS_ABWebServiceProcessor.java class, the HeaderHandler class implements the SOAPHandler interface and is used to create the WS-Security Header with the user name and password credentials retrieved from the softcoding record. The HeaderHandlerResolver class implements the HandlerResolver interface and is used to call the HeaderHandler class.