Java Reference
In-Depth Information
for a given request and the order in which those handlers will be invoked. Your resolver class
must implement the HandlerResolver interface, which defines the single method getHand-
lerChain , and the chain itself is simply represented as a List<Handler> . Note that you don't
have to call that method yourself from your client or test class; JAX-WS will do it for you. All
you need to do is implement that method to indicate what handlers are in this chain and then
set the chain into the service.
NOTE
Outbound messages (requests) are processed in the order specified in the handler chain list. Inbound
messages (responses), however, are processed in the opposite order.
Now that everything is set up, you'll use the JUnit test case in Example 6-12 to invoke the
service. All you have to do is attach an instance of the handler to the service proxy using its
setHandlerResolver method. As long as the instance you specify implements the Handler
interface or one of its subinterfaces (such as SOAPHandler ), you should be in business.
Example6-12.TestHandler.java
package com.soacookbook.ch03.test;
import static org.junit.Assert.*;
import com.soacookbook.ch03.*;
import com.soacookbook.ch03.handler.HelloHandlerResolver;
import com.soacookbook.ns.bin.*;
import org.apache.log4j.Logger;
import org.junit.Test;
import java.io.*;
/**
* Tests that the handler is called on an invocation to
* a service operation.
*/
public class HandlerTest {
private static final Logger LOGGER =
Logger.getLogger(HandlerTest.class);
private String name;
public HandlerTest() {
name = "Eben";
}
Search WWH ::




Custom Search