1 23 package com.sun.enterprise.webservice; 24 25 import java.lang.reflect.Method ; 26 27 import java.rmi.UnmarshalException ; 28 29 import javax.xml.namespace.QName ; 30 import javax.xml.rpc.JAXRPCException ; 31 import javax.xml.rpc.handler.Handler ; 32 import javax.xml.rpc.handler.GenericHandler ; 33 import javax.xml.rpc.handler.HandlerInfo ; 34 import javax.xml.rpc.handler.MessageContext ; 35 36 37 import com.sun.enterprise.Switch; 38 import com.sun.ejb.Container; 39 import com.sun.ejb.Invocation; 40 import com.sun.enterprise.InvocationManager; 41 42 import java.util.logging.Logger ; 43 import java.util.logging.Level ; 44 import com.sun.logging.LogDomains; 45 46 54 public class EjbContainerPostHandler extends GenericHandler { 55 56 private static Logger logger = 57 LogDomains.getLogger(LogDomains.EJB_LOGGER); 58 private WsUtil wsUtil = new WsUtil(); 59 60 public EjbContainerPostHandler() {} 61 62 public QName [] getHeaders() { 63 return new QName [0]; 64 } 65 66 public boolean handleRequest(MessageContext context) { 67 Invocation inv = null; 68 boolean continueProcessing = true; 69 70 try { 71 Switch theSwitch = Switch.getSwitch(); 72 InvocationManager invManager = theSwitch.getInvocationManager(); 73 inv = (Invocation) invManager.getCurrentInvocation(); 74 Container container = (Container) inv.container; 75 76 Method webServiceMethodInPreHandler = inv.getWebServiceMethod(); 77 78 if( webServiceMethodInPreHandler != null ) { 79 Method postHandlerMethod = 85 wsUtil.getInvMethod(inv.getWebServiceTie(), context); 86 if( !webServiceMethodInPreHandler.equals(postHandlerMethod) ) { 87 inv.exception = new UnmarshalException 88 ("Original method " + webServiceMethodInPreHandler + 89 " does not match post-handler method " + 90 postHandlerMethod); 91 } 92 } 93 } catch(Exception e) { 94 String errorMsg = "Exception while getting method for " + 95 ((inv != null ) ? 96 ((Container) inv.container).getEjbDescriptor().getName() : ""); 97 inv.exception = new UnmarshalException (errorMsg); 98 inv.exception.initCause(e); 99 } 100 101 if( inv.exception != null ) { 102 logger.log(Level.WARNING, "postEjbHandlerError", inv.exception); 103 wsUtil.throwSOAPFaultException(inv.exception.getMessage(), 104 context); 105 } 106 107 return true; 108 } 109 110 } 111 | Popular Tags |