I've created an Extension of GenericHandler called SOAPHeaderHandler. I placed log4j statements in the handler and can see the constructor being built. When I generate a SOAP message, however, I don't see the message related to the handleRequest method. I've registered the Handler in the stub as follows:
if (service == null) {
super.service = new com.ibm.ws.webservices.engine.client.Service();
}
else {
super.service = service;
}
List handlerInfoList = new ArrayList();
QName[] headersArr = null;
HandlerInfo handlerInfo = new HandlerInfo(com.xxxxxx.hdhp.business.debitcard.cardservices.CardServiceSOAPHeaderHandler.class,
null, headersArr);
handlerInfoList.add(handlerInfo);
service.getHandlerRegistry().setHandlerChain(new QName("MetavanteDebitCard"), handlerInfoList);
The Handler is:
public class AccountManagementSOAPHeaderHandler extends GenericHandler {
private static Logger logger = Logger.getLogger (AccountManagementSOAPHeaderHandler.class);
private HandlerInfo handlerInfo = null;
public AccountManagementSOAPHeaderHandler () {
logger.info("Constructing AccountManagementSOAPHeaderHandler");
}
/* (non-Javadoc)
* @see javax.xml.rpc.handler.GenericHandler#getHeaders()
*/
public QName[] getHeaders() {
logger.info("calling getHeaders()");
return null;
}
public boolean handleFault(MessageContext arg0) {
logger.info("Fault in AccountManagementSOAPHeaderHandler");
return true;
}
public boolean handleResponse(MessageContext arg0) {
logger.info("Response in AccountManagementSOAPHeaderHandler");
return true;
}
public void init(HandlerInfo arg0) {
logger.info("init in AccountManagementSOAPHeaderHandler");
handlerInfo = arg0;
super.init(arg0);
}
public void destroy() {
logger.info("--- In AccountManagementSOAPHeaderHandler.destroy ()");
}
public boolean handleRequest(MessageContext ctx) {
logger.debug("BEGIN handleRequest()");
if (ctx instanceof SOAPMessageContext) {
SOAPMessageContext context = (SOAPMessageContext) ctx;
logger.debug("instance of SOAPMessageContext");
try {
SOAPHeader header = context.getMessage().getSOAPPart()
.getEnvelope().getHeader();
logger.debug("SOAP Header is " + ((header==null)?"NULL":"NOT NULL"));
Iterator headers = header
.extractHeaderElements("http://schemas.xmlsoap.org/soap/actor/next");
while (headers.hasNext()) {
SOAPHeaderElement he = (SOAPHeaderElement) headers.next();
logger.info("HEADER Qn " + he.getElementName().getQualifiedName());
}
} catch (SOAPException x) {
logger.error("SOAPException while handlingRequest for SOAP: '" + x.getMessage() + "'");
}
}
return true;
}
and I've changed the web.xml as follows:
<service-ref>
<description>WSDL Service AccountManagerService</description>
<service-ref-name>service/AccountManagerService</service-ref-name>
<service-interface>com.medibank.www.AccountManagerService</service-interface>
<!-- <wsdl-file>WEB-INF/wsdl/AccountManagerService.asmx.wsdl</wsdl-file>-->
<jaxrpc-mapping-file>WEB-INF/AccountManagerService.asmx_mapping.xml</jaxrpc-mapping-file>
<service-qname xmlns:pfx="http://www.medibank.com/MBIWebServices/Access/Services/AccountManager/2004/06/">pfx:AccountManagerService</service-qname>
<port-component-ref>
<service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
</port-component-ref>
<port-component-ref>
<service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
</port-component-ref>
<handler>
<description>
</description>
<display-name></display-name>
<handler-name>AccountManagementSOAPHeaderHandler</handler-name>
<handler-class>com.xxxxx.hdhp.business.debitcard.accountmanagement.AccountManagementSOAPHeaderHandler</handler-class>
</handler>
</service-ref>
This is deployed on Websphere Application Server v6.0.2.35. Any ideas what the problem may be? Why do the logger statements in the handler never get executed? Have I failed to register the handler correctly? Do I need to specify which service methods get handled?