Implement Java clients calling Web Services

This page discusses - Implement Java clients calling Web Services

Implement Java clients calling Web Services

Implement Java clients calling Web Services

Generating a Java client proxy and a sample application from a WSDL document using the IBM SOAP run-time environment

The Web Service Client wizard assists you in generating a Java bean proxy and a sample application. The sample Web application demonstrates how to code a proxy file.

Prerequisites:

  1. Create a Web project.

  2. Discover and import a WSDL document into the Web project. You can only use a WSDL file that contains a service element.

To generate a Java client proxy and a sample application from a discovered WSDL document:

  1. Switch to the Resource perspective (Window > Open Perspective > Resource).

  2. In the Navigator view, select the Web project in which you want to generate a sample application (titan-web).

  3. Click File > New > Other. Select Web Services in order to display the various Web service wizards. Select the Web Service Client wizard. Click Next.

  4. Web Services panel: Select the type of proxy to be generated, and whether or not it will be tested.

    Web Services panel
  5. Client Environment Configuration page: Select the run-time environment and the server for your Web service client.

    1. Click Explore Options and select the IBM SOAP run-time environment and select the server on which you want to run your Web service client. If you want to use the Apache Axis 1.0 run-time environment or the IBM WebSphere V5 run-time environment, refer to the appropriate task.

    2. Select the type and name of project in which you want the Web service client created.

      • If you enter the name of an existing project, the project type field must match that of the existing project. Ensure that the project selected as the Client Web Project is different from the Service Web Project, or the service will be overwritten by the client's generated artifacts.

      • If you enter a name of a project that does not already exist, the wizard will create the project for you.

      • Note that the only project type supported for Axis and SOAP run-time clients is a Web project. If you want the client to be created in a Java, EJB, or Application Client project, you must select the WebSphere run-time environment for your client.

    3. Select an existing EAR or enter a unique name to associate the Web service client with a different EAR than the Web service EAR. Note: Selecting different EARs for the Web service and Web service client can reduce the chance of encountering run time errors, but will use more system resources.

    Client Environment Configuration page
  6. Web Service Selection panel: Enter the URI to the WSDL, WSIL, or HTML file that will be used to generate the Java bean. You can optionally generate a WSIL file from this file as well.

    Web Service Selection panel
  7. Web Service Binding Proxy Generation panel: Select the binding and proxy options.

    Web Service Binding Proxy Generation panel
  8. Web Service Test panel: Select the test facility that you will use to test the proxy, and the methods that you want included in the proxy. Click Finish.

    Web Service Test panel

Notes:

  • When defining custom mappings ensure the bean, serializer, and deserializer classes are on the build path of the Web project, otherwise the wizard will not accept their class names.

    mapping

    mapping
  • Indexed properties that result from WSDL XSD complex Types involving more than one occurrence of DOM Elements are not supported by the sample. SOAP encoded methods using indexed properties are not available for invocation. Literal XML encoded methods using indexed properties are available for invocation; however, the inputs and outputs must be specified as Literal XML.

  • Only the following types are supported by the sample application:

    • Members that use getters and setters.

    • All primitive types and corresponding Java types.

    • Java type String.

    • org.w3c.dom.Element

    • Java beans.

    • BigDecimal, GregorianCalendar, and Date. 0

Important: It is recommended that you select the service WSDL document rather than the binding WSDL document in order to generate a client proxy that contains the complete endpoint information. The service element is the basis for the Business Service that you will publish. You cannot publish a Business Service using a WSDL document that does not have service elements. If you generate a proxy from a WSDL binding document, you must call the setEndPoint() method to set an endpoint URL before you call any other method in the proxy. The proxy generated from a WSDL binding document is not automatically equipped with an endpoint URL.

The generated Java bean proxy provides a remote procedure call interface to the Web service. The sample Web application demonstrates how to code the proxy file.

Once you have generated your Java client proxy, you may test the methods of the Web service through the proxy using Web Services sample JSPs or the Universal test client. 1

  • If you have selected to test the generated proxy using Web service JSPs, the proxy is launched in a Web browser at the following URL: http://localhost:port/WebProjectClient/sample/WebService/TestClient.jsp. You can use this sample application to test the Web service by selecting a method, entering a value for the method, and clicking Invoke. The result of the method will display in the results pane.

  • If you have selected to test the generated proxy using the Universal Test Client, it will be launched in a browser window at the following URL: http://localhost:9080/UTC/preload?object=proxy.soap.ProxyNameProxy. In the Reference pane, under Object References, expand the proxy to display the methods of the Web service. Click the method you want to test, enter a value in the Parameters pane, and click Invoke. The result will be generated below.

  • Visit http://java.boot.by  for the updates. 2

Tutorials

  1. Appendix A. Additional materials
  2. WSAD 5.0 Practicing for IBM Test 000-287 Mind Map
  3. Deploy enterprise applications into servers
  4. Chapter 6. Assemble enterprise applications and deploy them in IBM WebSphere Application Server
  5. Configure resource and security-role references
  6. Design and develop custom tags
  7. Chapter 4. Demonstrate understanding of database connectivity and messaging within IBM WebShpere Application Server
  8. Chapter 5. EJB transactions
  9. Design and develop message-driven EJBs
  10. Design and develop entity EJBs
  11. Validate operational parameters of application server to support the enterprise application
  12. Chapter 1. Design, build and test reusable enterprise components
  13. Access container and server services from enterprise components
  14. Part I. Exam Objectives
  15. Explain implications of resource management on application design and implementation
  16. Manage end-user state and understand performance tradeoffs of using HTTP sessions
  17. Chapter 7. Validate, tune and troubleshoot an application within an IBM WebSphere Application Server environment
  18. Implement mechanisms for efficient inter-component calls
  19. IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide
  20. Chapter 3. Develop clients that access the enterprise components
  21. Implement Java clients calling Web Services
  22. Configure JMS connection factories and destinations
  23. Design, develop and test JSPs
  24. Use JTA to control transaction demarcation
  25. Manipulate transactional behavior of EJBs using deployment descriptors
  26. Implement mechanisms which support loose coupling between clients and components
  27. Identify misbehaving application components
  28. Preface
  29. WSAD 5.0 Practicing for IBM Test 000-287
  30. Part II. Appendixes
  31. Interact with connection pools to obtain and release connections
  32. Describe the effects of a server failure on the application
  33. Test and debug enterprise components
  34. Chapter 2. Design, build and test web components
  35. Chapter 2. Design, build and test web components