Web service client.
You insert a code snippet as follows:
- Within your Web service project, open a Java file to which you want to add the code.
- 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
- 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