That makes sense. Maybe by giving you my handler examples will help. I suggest commenting out all the code in the methods, and placing some debug statements
just to know it runs. Then you can go from there. IIRC doLDAPLogin is the only non-required interface method - but shows a cast between axis and java. This handler was used for digital signatures and encryption and therfore just comment out the code. package com.infoseg.mr.client.wsclient; import javax.xml.rpc.handler.HandlerInfo; import javax.xml.rpc.handler.Handler; import org.apache.axis.description.OperationDesc; import javax.xml.rpc.handler.MessageContext; import javax.xml.rpc.handler.HandlerInfo; import javax.xml.rpc.handler.soap.SOAPMessageContext; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.soap.SOAPEnvelope; import org.w3c.dom.Document; import java.util.Map; import javax.security.auth.login.*; import javax.security.auth.callback.CallbackHandler; import java.security.cert.*; import java.security.PrivateKey; import javax.crypto.*; import javax.crypto.spec.DESedeKeySpec; import javax.xml.rpc.JAXRPCException; import javax.security.auth.login.LoginException; import gov.sefaz.fw.fwlog.Fwlog; import com.infoseg.mr.security.*; /** <P> Implementa um Axis Handler. Atua como um XML firewall para todos os pedidos e repostas para o web service servidor. </P> */ public class ClientHandler implements Handler { private static final String securityDomain = "wssDomain"; private String elementToEncrypt = null; private String host = null; private boolean debug; private X509Certificate cert = null; private SecretKey secretKey = null; private PrivateKey privateKey = null; private String jaas_prop = null; /** Class contructor **/ public ClientHandler() { } /** Gerencia uma requisição SOAP no Axis. <p> @param context Tudo disponível de SOAP message - headers, envelopes, body etc. @return boolean retorno true para sucesso ou false para parar o processamento */ public boolean handleRequest(MessageContext context) { try { Fwlog.debug(this, Fwlog.WI, "Entered Client handler handleRequest()..."); //Login user via LDAP if (!doLDAPLogin(context)) { throw new LoginException("\n\nClientHandler::handleRequest failed, could not **LOGIN** \n\n"); } SOAPMessageContext soapCtx = (SOAPMessageContext)context; //Get SOAP message to encrypt and sign SOAPMessage soapMsg = soapCtx.getMessage(); org.w3c.dom.Document doc = SOAPUtility.toDocument(soapMsg); Fwlog.debug(this, Fwlog.WI, "Client is signing this SOAP Document: \n\n" + XMLHelper.getXml(doc)); if(!SecurityHelper.sign(doc, cert, privateKey, debug)) { throw new IllegalStateException("\n\nClientHandler::handleRequest failed, could not **SIGN** soap message\n\n"); } Fwlog.debug(this, Fwlog.WI, "Client is encrypting this SOAP Document: \n\n" + XMLHelper.getXml(doc)); if (!SecurityHelper.encrypt(doc, elementToEncrypt, secretKey, debug)) { throw new IllegalStateException("\n\nClientHandler::handleRequest failed, could not **ENCRYPT** soap message\n\n"); } soapMsg = SOAPUtility.toSOAPMessage(doc); soapCtx.setMessage(soapMsg); } catch (Exception e) { Fwlog.error(this, Fwlog.WI, e); throw new JAXRPCException(e.toString(), e); } Fwlog.debug(this, Fwlog.WI, "ClientHandler: ... handleRequest executed"); return true; } /** Gerencia uma resposta SOAP no Axis. <p> @param context Tudo disponível de SOAP message - headers, envelopes, body etc. @return boolean retorno true para sucesso ou false para parar o processamento. */ public boolean handleResponse(MessageContext context) { try { Fwlog.debug(this, Fwlog.WI, "Entered Client handler handleResponse()..."); //Login user via LDAP if (!doLDAPLogin(context)) { throw new LoginException("\n\nClientHandler::handleResponse failed, could not **LOGIN** \n\n"); } SOAPMessageContext soapCtx = (SOAPMessageContext)context; SOAPMessage soapMsg = soapCtx.getMessage(); org.w3c.dom.Document doc = SOAPUtility.toDocument(soapMsg); Fwlog.debug(this, Fwlog.WI, "Client is decrypting this SOAP Document: \n " + XMLHelper.getXml(doc)); if (!SecurityHelper.decrypt(doc, secretKey, debug)) { throw new IllegalStateException("\n\nClientHandler::handleResponse failed, could not **DECRYPT** soap message\n\n"); } Fwlog.debug(this, Fwlog.WI, "Client is validating this SOAP Document: \n" + XMLHelper.getXml(doc)); if (!SecurityHelper.verify(doc)) { throw new IllegalStateException("\n\nClientHandler::handleResponse failed, could not **VERIFY** soap message\n\n"); } soapMsg = SOAPUtility.toSOAPMessage(doc); if (debug) { Fwlog.debug(this, Fwlog.WI, "\n\nClientHandler::handleResponse returning Xml Signature validated, decrypted and deserialized XML doc to SOAP service: \n\n" + XMLHelper.getXml(doc)); } soapCtx.setMessage(soapMsg); } catch (Exception e) { Fwlog.error(this, Fwlog.WI, e); throw new JAXRPCException(e.toString(), e); } Fwlog.debug(this, Fwlog.WI, "ClientHandler: ... handleResponse executed"); return true; } /** Gerencia um erro ocorrido com esta requisição SOAP no Axis. <p> @param context Tudo disponível de SOAP message - headers, envelopes, body etc. @return boolean retorno true para sucesso ou false para parar o processamento */ public boolean handleFault(MessageContext context) { Fwlog.debug(this, Fwlog.WI, "ClientHandler: In handleFault"); return true; } /** Carrega todos os parâmetros de configuração para o funcionamento do WS-Security. <p> @param config Basicamente um HashMap definido no arquivo deploy.wssd para o web service que permite receber os variavies do usuário. */ public void init(HandlerInfo config) { Fwlog.debug(this, Fwlog.WI, "ClientHandler: init ..."); try { jaas_prop = System.getProperty("jaas.prop"); if (null == jaas_prop) { throw new IllegalStateException("jaas_prop not set, must point to login config file 'wssDomain.cfg' needed for java.security.auth.login.config"); } Map configProps = config.getHandlerConfig(); if (configProps.containsKey("elementToEncrypt")) { elementToEncrypt = (String)configProps.get("elementToEncrypt"); } else { throw new IllegalStateException("Handler chain config property missing: elementToEncrypt"); } if (configProps.containsKey("host")) { host = (String)configProps.get("host"); } else { throw new IllegalStateException("Handler chain config property missing: host"); } if (configProps.containsKey("verbose")) { String verbose = (String)configProps.get("verbose"); if (verbose.equalsIgnoreCase("on")) { debug = true; } else if (verbose.equalsIgnoreCase("off")) { debug = false; } else { throw new IllegalStateException("verbose config property not 'on' or 'off': " + verbose); } } else { throw new IllegalStateException("Handler chain config property missing: verbose"); } } catch (Exception e) { Fwlog.error(this, Fwlog.WI, e); throw new JAXRPCException(e.toString(), e); } } /** Esse metodo precisa ser implementado via interface Handler */ public void destroy() { } /** Esse metodo precisa ser implementado via interface Handler @return QName volta null */ public javax.xml.namespace.QName[] getHeaders() { return null; } /** Logar o usário <p> @param context Tudo disponível de SOAP message - headers, envelopes, body etc. @return true ou false */ public boolean doLDAPLogin(javax.xml.rpc.handler.MessageContext javaxcontext) { try { org.apache.axis.MessageContext mc = (org.apache.axis.MessageContext) javaxcontext; //set jass config parameter on every call to prevent environment hell System.getProperties().setProperty("java.security.auth.login.config", this.jaas_prop); // login user via JAAS CallbackHandler callbackHandler = new WSSCallbackHandler(mc, this.host); LoginContext lc = new LoginContext(securityDomain, callbackHandler); lc.login(); Fwlog.debug(this, Fwlog.WI, "User logged in successfully: " + mc.getUsername()); // Get instance from singleton WSSecurityManager wsm = WSSecurityManager.getInstance(); // Get get X509 certificate needed to sign message this.cert = wsm.getCert(mc.getUsername()); // Get PrivateKey needed to sign X509 Certificate this.privateKey = wsm.getPrivateKey(mc.getUsername()); // Get SecretKey needed to encrypt/decrypt message this.secretKey = wsm.getSecretKey(mc.getUsername()); Fwlog.debug(this, Fwlog.WI, "Got cert, pk and sk for user: " + mc.getUsername()); return true; } catch (Exception e) { Fwlog.error(this, Fwlog.WI, "ServiceHandler::doLDAPLogin -- Exception: "); Fwlog.error(this, Fwlog.WI, e); return false; } } } Let me know if you need any of these dependant classes - don't think you will. HTH, iksrazal --- JR Ruggentaler <[EMAIL PROTECTED]> wrote: > I use eclipse and in the debugger the classpath > looks correct. I traced into the code and in > org.apache.axis.handlers.HandlerChainImpl class > newHandler() method the code is throwing a class > cast exception: > > private Handler newHandler(HandlerInfo > handlerInfo) { > try { > Handler handler = > (Handler)handlerInfo.getHandlerClass() > .newInstance(); > handler.init(handlerInfo); > return handler; > } catch (Exception ex) { > String messageText = > > Messages.getMessage("NoJAXRPCHandler00", > > handlerInfo.getHandlerClass().toString()); > throw new JAXRPCException(messageText, > ex); > } > } > > The call to neInstance() above casts the result to > javax.xml.rpc.handler.Handler but > SimpleSessionHandler does not implement > javax.xml.rpc.handler.Handler interface. It > implements org.apache.axis.Handler and is a subclass > of org.apache.axis.handlers.BasicHandler. I must be > installing the handler in the wrong object. Any idea > how I can install the SimpleSessionHandler using the > code from DynamicInvoker class in the axis examples > via code? > > Debugger info: > System.getProperty("java.class.path") > C:\eclipse3\utilities\MohawkWebClient\bin;C:\eclipse3\utilities\MohawkWebClient\lib\axis.jar;C:\eclipse3\utilities\MohawkWebClient\lib\axis-ant.jar;C:\eclipse3\utilities\MohawkWebClient\lib\commons-discovery-0.2.jar;C:\eclipse3\utilities\MohawkWebClient\lib\commons-logging-1.0.4.jar;C:\eclipse3\utilities\MohawkWebClient\lib\jaxrpc.jar;C:\eclipse3\utilities\MohawkWebClient\lib\log4j-1.2.8.jar;C:\eclipse3\utilities\MohawkWebClient\lib\saaj.jar;C:\eclipse3\utilities\MohawkWebClient\lib\wsdl4j-1.5.1.jar;C:\eclipse3\utilities\MohawkWebClient\lib\activation.jar;C:\eclipse3\utilities\MohawkWebClient\lib\mail.jar > > J.R. > -----Original Message----- > From: trebor iksrazal [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 19, 2005 12:13 PM > To: axis-user@ws.apache.org > Subject: RE: Axis 1.2 handlers > > > Try googling on this error - its a common one that > has > nothing to do with handlers. > > My guess is that its really not in your client > classpath. If you're able try executing the client > with ant, which does a good job of resolving this > type > of stuff. Otherwise i'd double check your classpath > very carefully. > > --- JR Ruggentaler <[EMAIL PROTECTED]> wrote: > > > The server side is a Apple WebObjects application > so > > I added activation.jar and mail.jar to the > classpath > > and restarted the server. I also added > > activation.jar and mail.jar to the client > classpath. > > I reran the client and it threw the same > exception. > > The exception is actually from the client. The > > client works fine without the changes to add the > > SimpleSessionHandler but throws the previously > > posted exception when I add the > > SimpleSessionHandler. My real goal it to add a > > custom handler to manage sessions in a WebObjects > > compatible manner. WebObjects uses several cookies > > in the HTTP headers to communicate session info > for > > state management. > > > > J.R. > > > > -----Original Message----- > > From: trebor iksrazal [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, October 19, 2005 11:15 AM > > To: axis-user@ws.apache.org > > Subject: RE: Axis 1.2 handlers > > > > > > Try putting activation.jar and mail.jar in your > > servlet container. > > > > --- JR Ruggentaler <[EMAIL PROTECTED]> wrote: > > > > > I modifier DynamicInvoker > > > > > > public HashMap invokeMethod( > > > String operationName, String > portName, > > > String[] args) > > > throws Exception { > > > String serviceNS = null; > > > String serviceName = null; > > > String operationQName = null; > > > > > > System.out.println("Preparing Axis > dynamic > > > invocation"); > > > Service service = > selectService(serviceNS, > > > serviceName); > > > Operation operation = null; > > > org.apache.axis.client.Service dpf = new > > > org.apache.axis.client.Service(wsdlParser, > > > service.getQName()); > > > > > > Vector inputs = new Vector(); > > > Port port = > selectPort(service.getPorts(), > > > portName); > > > if (portName == null) { > > > portName = port.getName(); > > > } > > > > > > // Add handler > > > HandlerRegistry hr = > > > dpf.getHandlerRegistry(); > > > List handlers = > > > hr.getHandlerChain(QName.valueOf(portName)); > > > handlers.add(new > > > HandlerInfo(SimpleSessionHandler.class, new > > > HashMap(), null)); > > > > > > to add the SimpleSessionHandler but this caused > > the > > > following exception: > > > > > > Reading WSDL document from > > > > > > 'http://localhost:4444/cgi-bin/WebObjects/MohawkWebService.woa/ws/.MohawkWS?wsdl' > > > - Unable to find required classes > > > (javax.activation.DataHandler and > > > javax.mail.internet.MimeMultipart). Attachment > > > support is disabled. > > > Preparing Axis dynamic invocation > > > Executing operation getFilters with parameters: > > > AxisFault > > > faultCode: > > > > > > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException > > > faultSubcode: > > > faultString: javax.xml.rpc.JAXRPCException: > > Unable > > > to create handler of type class > > > org.apache.axis.handlers.SimpleSessionHandler > > > faultActor: > > > faultNode: > > > faultDetail: > > > > > > > > > {http://xml.apache.org/axis/}stackTrace:javax.xml.rpc.JAXRPCException: > > > Unable to create handler of type class > > > org.apache.axis.handlers.SimpleSessionHandler > > > at > > > > > > org.apache.axis.handlers.HandlerChainImpl.newHandler(HandlerChainImpl.java:247) > > > at > > > > > > org.apache.axis.handlers.HandlerChainImpl.<init>(HandlerChainImpl.java:77) > > > at > > > > > > org.apache.axis.handlers.HandlerInfoChainFactory.createHandlerChain(HandlerInfoChainFactory.java:42) > > > at > > > > > > org.apache.axis.client.AxisClient.getJAXRPChandlerChain(AxisClient.java:274) > > > at > > > > > > org.apache.axis.client.AxisClient.invoke(AxisClient.java:140) > > > at > > > > > > org.apache.axis.client.Call.invokeEngine(Call.java:2765) > > > at > > > > org.apache.axis.client.Call.invoke(Call.java:2748) > > > at > > > > org.apache.axis.client.Call.invoke(Call.java:2424) > > > at > > > > org.apache.axis.client.Call.invoke(Call.java:2347) > > > at > === message truncated === "None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe" __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com