Web Services Development: Using Client Proxy Templates

This document describes the following:


1. Using Client Proxy Templates

OEPE provides a set of ready-to-use common code snippets that you can access through templates and insert in your JAX-WS-enabled Web services Java code. This is useful when you instantiate a Web service client.

You insert a code snippet as follows:

  1. Within your Web service project, open a Java file to which you want to add the code.

  2. Place the cursor at a particular location, and then press Ctrl+Space. This opens a descriptive list of titles of the code snippets available for your code, as Figure 1 shows. To display a detailed description and the snippet itself, select an item from the list.



    Figure 1.
    Adding a Code Snippet


  3. Double-click the snippet title to insert it in your code.

Using the following automatically-generated code snippets, you can reference new or modify an existing Web service client:

  • Default WSDL location client Web service - use this option to create a basic Web service client reference.
    The generated code will be of the following format:
      SomeService service = new SomeService();
      SomePortType port = service.getSomePort();
      port.someOperation();
    
  • Specify WSDL location client Web service - use this option to create a basic Web service client reference, with the local declaration allowing for the URL specification.
    The generated code will be of the following format:
      SomeService service = new SomeService(new URL("http://localhost:7001/SomeProject/SomeService?wsdl"), 
                                            new QName("SomeNamespace", 
                                            "SomeService"));
      SomePortType port = service.getSomePort();
      port.someOperation();
    
  • Web service reference client service - use this option to create a basic Web service client reference field declaration, where you will be required to specify the URL.
    The generated code will be of the following format:
      // variable declaration - implementation injected by container
      @WebServiceRef(wsdlLocation="http://localhost:7001/SomeProject/SomeService?wsdl")
      SomeService service;
    
      // Web service call in the method block
      SomePortType port = service.getSomePort();
      port.someOperation(); 
    
  • Attach programmatic client-side handler chain - use this option to attach a handler chain programmatically for a locally declared client service.
    The generated code will be of the following format:
      SomePortType port = service.getSomePort();
    
      Binding binding = port.getBinding();
        
      // can create new list or use existing one
      List handlerList = binding.getHandlerChain();
        
      handlerList.add(new HandlerChainImplementation());
      binding.setHandlerChain(handlerList);
      port.someOperation();
    
  • Web service reference client service with a handler chain - use this option to create a basic Web service client reference field declaration, where you will be required to specify the URL and a handler chain file location.
    The generated code will be of the following format:
      // variable declaration - implementation injected by container
      @javax.jws.HandlerChain(file="myhandler.xml")
      @WebServiceRef(wsdlLocation="http://localhost:7001/SomeProject/SomeService?wsdl")
      SomeService service;
    
      // Web service call in the method block
      SomePortType port = service.getSomePort();
      port.someOperation(); 
    

Note that, with the exception of the template that you use to programmatically attach a handler chain for a locally declared client service, all other templates require a WebLogic Web service-generated client JAR with attached source located in the WebConent/WEB-INF/lib directory.



2. Related Information