Part 5: Creating a Web Service Proxy
If you need to access a web service from a Java client, you will need a java web service proxy. JDeveloper provides a wizard that will create one for you.The purpose of a proxy client is to provide access to the web services API as if it were a local service. All the web service proxy generator needs is the web service WSDL. From that, it determines the API and generates the required classes.
Step 1: Creating the Web Service Proxy

In this section, you use a wizard to generate a Java proxy for calling a web service. Once complete, you can create a client to connect to it and use it.

  1. Create a new empty project. Right-click the Annotation project node and select New > From Gallery . In the New Gallery select General > Projects in the Categories list and Custom Project in the Items list. Click OK.

    new gallery

  2. Create a new Generic Project and name it ClientTester and click Finish.

    create generic project fnish

  3. To use a client, you need to have the HTTP Analyzer up and running with one of your services. If it is not running, expand the Annotation project, and test the MyCompany class in the HTTP Analyzer. Confirm that it is up and working. (You could use any of the web services you created.)

  4. Right-click the WSDL URL in the analyzer and select Copy. Do not close the HTTP Analyzer tab.

    h t t p analyzer
  5. To generate the proxy, right-click the ClientTester project and select New > From Gallery .

    application navigator

  6. In the New Gallery, expand the Business Tier node and select Web Services in the Categories list. Select the Web Service Client and Proxy item and click OK.

    new gallery

    This action invokes the Create Web Service Proxy wizard.

  7. Click Next to dismiss the Welcome page

  8. In the Select Web Service Description page, you specify the location of the WSDL service.
    Paste the URL you copied from the from the HTTP Analyzer in the previous step into the WSDL Document URL. Select Copy WSDL Into Project and click Next.

    create web service proxy step 3

  9. Accept the default for the mapping options and click Next.

    create web service proxy step 2

  10. If you needed to change the Endpoint URL to point to a different server, you would do so here. Click Next.

    create web service proxy step 5

  11. For the rest of the pages in the wizard, the default values are fine. Either click Next to examine the remaining steps, or click Finish to create the proxy.

    create web service proxy step 9

  12. Click Save All save all to save your work.

  13. Expand the ClientTester > Applications Sources > annotation > MyCompanyWSProxy nodes in the Applications window, which should look like the image below.

    application navigator

Step 2: Creating and Testing the Client Proxy

In this section you update the client class to invoke the web service proxy and return the result to the message window.

  1. In the Applications window, Double-click  MyCompanyPortClient.java to open it in the editor.

    application navigator

  2. Add the following code to the main() method of the MyCompanyPortClient class:



    code editor
  3. Click Save All save all to save your work.

  4. Now you can test the client proxy.

  5. In the Applications window, right-click the MyCompanyPortClient.java file and select Run.
    (The HTTP Analyzer must be up and running to process the client request. If it is not up, go back to the Annotation project, right-click  MyCompany.java and select Test Web Service. If you get errors and the test does not run, shut down JDeveloper and restart it.)

    application navigator

  6. The results of the client can be viewed in the ClientTester.jpr - Log window. If successful, you should see Administration is at Redwood City.

    running log window

  7. Close all tabs in the editor and collapse all of the projects in the Applications window.


Bookmark Print Expand all | Hide all
Back to top
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.