[savara-commits] savara SVN: r391 - trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Sep 6 10:37:43 EDT 2010


Author: objectiser
Date: 2010-09-06 10:37:42 -0400 (Mon, 06 Sep 2010)
New Revision: 391

Added:
   trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java
Modified:
   trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
   trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
Log:
Extract message type from message body when operation metadata only has 'genericParam'. Currently only deals with doclit style.

Modified: trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java	2010-09-06 10:37:33 UTC (rev 390)
+++ trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java	2010-09-06 14:37:42 UTC (rev 391)
@@ -17,6 +17,7 @@
  */
 package org.jboss.savara.validator.jbosswsnative;
 
+import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
 import javax.xml.ws.handler.MessageContext;
@@ -51,17 +52,10 @@
 				System.out.println(DOMWriter.printNode(soapEnv, true));
 			}
             
-			if (ctx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
-				org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
-					(org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)ctx;
-			    org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
-			    
-			    if (opmetadata.getInputParameters().size() == 1) {
-			    	ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
-			    	
-					logger.info("Client: Inbound message type="+pmd.getXmlName());
-			    }
-			}
+			QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
+			
+			logger.info("Client: Inbound message type="+mesgType);
+
 		} catch (SOAPException ex) {
 			logger.error("Cannot trace SOAPMessage", ex);
 		}
@@ -82,17 +76,10 @@
 				System.out.println(DOMWriter.printNode(soapEnv, true));
 			}
             
-			if (ctx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
-				org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
-					(org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)ctx;
-			    org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
-			    
-			    if (opmetadata.getInputParameters().size() == 1) {
-			    	ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
-			    	
-					logger.info("Client: Outbound message type="+pmd.getXmlName());
-			    }
-			}
+			QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
+			
+			logger.info("Client: Outbound message type="+mesgType);
+
 		} catch (SOAPException ex) {
 			logger.error("Cannot trace SOAPMessage", ex);
 		}

Added: trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java	                        (rev 0)
+++ trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java	2010-09-06 14:37:42 UTC (rev 391)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.savara.validator.jbosswsnative;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.ws.metadata.umdm.ParameterMetaData;
+
+/**
+ * This class provides utility functions for the JBossWS native interceptors.
+ *
+ */
+public class JBossWSNativeInterceptorUtil {
+
+	/**
+	 * This method determines the message type associated with the supplied SOAP
+	 * message context.
+	 * 
+	 * @param soapCtx The SOAP message context
+	 * @return The message type
+	 * @throws SOAPException Failed to determine the message type
+	 */
+	public static QName getMessageType(SOAPMessageContext soapCtx) throws SOAPException {
+		QName ret=null;
+		
+		if (soapCtx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
+			org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
+				(org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)soapCtx;
+		    org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
+		    
+		    if (opmetadata.getInputParameters().size() == 1) {
+		    	ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
+		    	
+		    	// TODO: Find out why 'genericParam' is generated when the parameter
+		    	// is a complex type
+				if (pmd.getXmlName().getLocalPart().equals("genericParam")) {
+					
+					// Extract message value
+		            SOAPBody soapBody = soapCtx.getMessage().getSOAPPart().getEnvelope().getBody();
+					
+		            SOAPElement elem=(SOAPElement)soapBody.getChildElements().next();
+		            
+		            if (elem instanceof SOAPFault) {
+		            	SOAPFault fault=(SOAPFault)elem;
+		            	
+		            	SOAPElement detail=(SOAPElement)fault.getDetail().getChildElements().next();
+		            	
+		            	ret = detail.getElementQName();
+		            	
+		            } else {
+		            	ret = elem.getElementQName();
+		            }
+				} else {
+					ret = pmd.getXmlName();
+				}
+		    }
+		}
+
+		return(ret);
+	}
+
+}

Modified: trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
===================================================================
--- trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java	2010-09-06 10:37:33 UTC (rev 390)
+++ trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java	2010-09-06 14:37:42 UTC (rev 391)
@@ -17,8 +17,12 @@
  */
 package org.jboss.savara.validator.jbosswsnative;
 
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
@@ -51,21 +55,12 @@
 				System.out.println(DOMWriter.printNode(soapEnv, true));
 			}
 			
-			Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
-			
-			logger.info("Server: Inbound message for operation="+operation);
+			//Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
+			//logger.info("Server: Inbound message for operation="+operation);
             
-			if (ctx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
-				org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
-					(org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)ctx;
-			    org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
-			    
-			    if (opmetadata.getInputParameters().size() == 1) {
-			    	ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
-			    	
-					logger.info("Server: Inbound message type="+pmd.getXmlName());
-			    }
-			}
+			QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
+
+			logger.info("Server: Inbound message type="+mesgType);
 		    
 		} catch (SOAPException ex) {
 			logger.error("Cannot trace SOAPMessage", ex);
@@ -87,22 +82,12 @@
             	System.out.println(DOMWriter.printNode(soapEnv, true));
             }
             
-			Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
-			
-			logger.info("Server: Outbound message for operation="+operation);
-			if (operation != null) logger.info("operation class="+operation.getClass());
-          
-			if (ctx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
-				org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
-					(org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)ctx;
-			    org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
-			    
-			    if (opmetadata.getInputParameters().size() == 1) {
-			    	ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
-			    	
-					logger.info("Server: Outbound message type="+pmd.getXmlName());
-			    }
-			}
+			//Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
+			//logger.info("Server: Outbound message for operation="+operation);
+
+			QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
+
+			logger.info("Server: Outbound message type="+mesgType);
 		} catch (SOAPException ex) {
 			logger.error("Cannot trace SOAPMessage", ex);
 		}



More information about the savara-commits mailing list