我正在开发一个Jax Ws,我想添加Soap Handler用于WS身份验证。添加了一个处理程序链xml和一个Soap Handler类,但代码从不调用Soap Handler的方法。我使用JDK 8和Tomcat 7.可能是什么问题? 我的处理程序链xml如下:
>9
我的肥皂处理程序类a:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE javaee:handler-chains>
<javaee:handler-chains xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<javaee:handler-chain>
<javaee:handler>
<javaee:handler-class>com.vw.AuthHandler
</javaee:handler-class>
</javaee:handler>
</javaee:handler-chain>
</javaee:handler-chains>
我的服务如下:
import java.io.PrintStream;
import java.io.StringReader;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class AuthHandler implements SOAPHandler<SOAPMessageContext> {
private static PrintStream out = System.out;
@Override
public Set<QName> getHeaders() {
return Collections.emptySet();
}
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!outboundProperty) {
System.out.println("Hello!");
return true;
}
return false;
}
@Override
public boolean handleFault(SOAPMessageContext context) {
System.out.println("Hello!");
return false;
}
@Override
public void close(MessageContext context) {
System.out.println("Hello!");
}
}