You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/11/17 05:01:50 UTC

svn commit: r476045 [1/2] - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/ src/org/apache/axis2/jaxws/client/proxy/ src/org/apache/axis2/jaxws/description/impl/ src/org/apache/axis2/jaxws/i18n/ src/org/apache/axis2/jaxws/ma...

Author: scheu
Date: Thu Nov 16 20:01:48 2006
New Revision: 476045

URL: http://svn.apache.org/viewvc?view=rev&rev=476045
Log:
AXIS2-1603
Contributor:Rich Scheuerle
Refactored Method Marshaller + RPC Lit processing

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/PDElement.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java
Removed:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitBareMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitWrappedMethodMarshaller.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/ClassUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/PropertyInfo.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageRPCTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddressBookTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java Thu Nov 16 20:01:48 2006
@@ -27,6 +27,8 @@
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.MessageInternalException;
+import org.apache.axis2.jaxws.message.util.MessageUtils;
+import org.apache.axis2.jaxws.util.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Thu Nov 16 20:01:48 2006
@@ -411,12 +411,14 @@
 		//FIXME: The protocol should actually come from the binding information included in
 	    // either the WSDL or an annotation.
 		return cf.createMethodMarshaller(SOAPBinding.Style.DOCUMENT, parameterStyle, 
-                serviceDesc, endpointDesc, operationDesc, Protocol.soap11);
+                serviceDesc, endpointDesc, operationDesc, Protocol.soap11, true);
 	}
 	
 	private MethodMarshaller createRPCLitMethodMarshaller(MethodMarshallerFactory cf){
-		return cf.createMethodMarshaller(SOAPBinding.Style.DOCUMENT, SOAPBinding.ParameterStyle.WRAPPED,
-                serviceDesc, endpointDesc, operationDesc, Protocol.soap11);
+        //    FIXME: The protocol should actually come from the binding information included in
+        // either the WSDL or an annotation.
+        return cf.createMethodMarshaller(SOAPBinding.Style.DOCUMENT, SOAPBinding.ParameterStyle.WRAPPED,
+                serviceDesc, endpointDesc, operationDesc, Protocol.soap11, true);
 	}
 	protected boolean isDocLitBare(){
 		SOAPBinding.ParameterStyle methodParamStyle = operationDesc.getSoapBindingParameterStyle();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java Thu Nov 16 20:01:48 2006
@@ -28,8 +28,8 @@
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
-import org.apache.axis2.jaxws.util.ClassUtils;
 import org.apache.axis2.jaxws.util.JavaUtils;
+import org.apache.axis2.jaxws.util.XMLRootElementUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -239,7 +239,7 @@
      * @return Class or null
      */
     private static Class getElement(Class cls) {
-        if (!ClassUtils.isXmlRootElementDefined(cls)) {
+        if (!XMLRootElementUtil.isElementEnabled(cls)) {
             return null;
         } 
         return cls;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Thu Nov 16 20:01:48 2006
@@ -93,7 +93,7 @@
 JAXBWrapperErr3=An internal assertion error occurred. The child objects or child names argument to the wrap method is null.
 JAXBWrapperErr4=An internal assertion error occurred. The number of child objects does not match the number of child names in the wrap method.
 JAXBWrapperErr5=An internal assertion error occurred. The number of child names does not match the number of bean properties in the {0} JAXB class.
-JAXBWrapperErr6=An internal assertion error occurred. The {0} JAXB object does not have a {1} bean property.
+JAXBWrapperErr6=An internal assertion error occurred. The {0} JAXB object does not have a {1} xml property.
 JAXBWrapperErr7=An internal assertion error occurred. The value of the method parameters that holds the child objects to create the JAXBObject is null.
 JAXBSourceNamespaceErr=The DOMSource value must be Namespace Aware.
 AttachmentsNotSupported=SAAJ attachments are not supported.

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java Thu Nov 16 20:01:48 2006
@@ -25,76 +25,86 @@
 /**
  * This class marshals and unmarshals method invocations.
  * 
+ * Here is the high-level view of marshalling:
+ * SIGNATURE_ARGS ---> Type Enabled Object  -----> Element Enabled Object ---> MESSAGE (XML)
+ * 
+ * The Signature objects are the objects from the SEI method signature.  They may be values or holders of values.
+ * The values are "type enabled objects" (i.e. String), which means that they cannot be marshalled or unmarshalled.
+ * @see org.apache.axis2.jaxws.util.XMLRootElementUtils for details on Type Enabled and Element Enabled objects.
+ * 
+ * The values are enhanced (if necessary) into Element Enabled Objects.  These can be marshalled or unmarshalled using JAXB.
+ * @see org.apache.axis2.jaxws.marshaller.impl.alt.PDElement
+ * 
+ * The element enabled objects are put onto the message.
+ * 
+ * The high-level view of unmarshalling is the reverse.
+ * SIGNATURE_ARGS <---- Type Enabled Object  <----- Element Enabled Object <---- MESSAGE (XML)
+ * 
+ * See the specific MethodMarshaller implementations to see how doc/lit wrapped, doc/lit bare and rpc/lit affect
+ * the process of going from SIGNATURE_ARGS to the element enabled objects.
+ * 
  * If there are any problems, a WebServiceException is thrown.  (Each of the methods is guranteed to catch any unchecked exception and wrap
  * it in a WebServiceException).
  */
 public interface MethodMarshaller {
 	
 	/**
-	 * This method converts java Objects in to a Message. Used on Client side to convert input method object to Message that is sent on wire.
-	 * 
-	 * NONWRAP CASE:
-	 * creates a request message. The input object to a non wrapped wsdl will be a object (mainly a JAXB Object) that will
-	 * have all the payload data or method parameter data already setup. So the message will be created by converting input object in to a JAXBBlock and
-	 * attaching the Block Message to soap body.
-	 * 
-	 * WRAP CASE:
-	 * 
-	 * create request message. It reads RequestWrapper annotation from OperationDescription and reads the class name, then reads
-	 * all the webParam annotation on the method and uses JAXBWrapTool to wrap the request as jaxbObject. Create JAXBblock from the jaxbObject
-	 * reads Biniding provider properties and set them on request message and return request message.
-	 * @param object
-	 * @return
+	 * This method converts SIGNATURE_ARGS into a Message. 
+     * It is used on the client
+     *
+	 * @param signatureArgs
+	 * @return Message
 	 */
-	public Message marshalRequest(Object[] object) throws WebServiceException; 
+	public Message marshalRequest(Object[] signatureArgs) throws WebServiceException; 
 	
 	/**
-	 * This method creates Message from a returnObject and input parameters of holder type. This is a case where we have method with return
-	 * type and input parameters as holders. Used on Server side to convert service methods return type to Message that is then sent on wire.
-	 * @param jaxbObject
-	 * @return
+	 * This method converts the SIGNATURE_ARGS and RETURN object into a Message.
+     * It is used on the server
+     * 
+	 * @param returnObject
+     * @param signatureArgs
+	 * @return Message
 	 */
-	public Message marshalResponse(Object returnObject, Object[] holderObjects)throws WebServiceException;
+	public Message marshalResponse(Object returnObject, Object[] signatureArgs)throws WebServiceException;
 	
-	/**
-	 * This method creates Fault Message from a Throbale input parameter. 
-	 * Used on Server side to convert Exceptions to Fault Message that is then sent on wire.
-	 * @param jaxbObject
-	 * @return
-	 */
-	public Message marshalFaultResponse(Throwable throwable) throws WebServiceException;
-	/**
-	 * This method converts Message to java objects. Used on Server Side to this extract method input parameters from message and invokes method on service
-	 * with found input parameters on ServiceEndpoint.
-	 * @param message
-	 * @return
-	 */
-	public Object[] demarshalRequest(Message message)throws WebServiceException;
 	
+    /**
+     * This method converts the Message into a SIGNATURE_ARGS
+     * It is used on the server
+     * 
+     * @param message
+     * @return signature args
+     */
+    public Object[] demarshalRequest(Message message)throws WebServiceException;
+    
 	/**
-	 * This method converts Message to Object. Used on Client side when converting response message from Server to ResponseWrapper/return type of method that
-	 * Client uses to map.
-	 * 
-	 * NONWRAP CASE:
-	 * creates return result that client expects from the method call. This method reads the method return type
-	 * or uses webResult annotation and creates JAXBBlock from the response context and returns the business object associated with the JAXBBlock.
-	 * 
-	 * WRAP CASE:
-	 * creates return result that client expects from the method call. It reads response wrapper annotation then reads OM from the
-	 * response message context and creates JAXBBlock from the OMElement on messageContext. It then reads the webresult annotation to gather the return parameter
-	 * name and creates the result object for it by reading the property object from JAXBBlock's business object using PropertyDescriptor. 
-	 * 
+	 * This method gets the objects from the Message and sets them onto the SIGNATURE_ARGS
+     * It also returns the RETURN object.
+     * Called on client
+     * 
 	 * @param message
-	 * @return
+     * @param signatureAgs (same array of args that were used for marshalRequest.  The out/inout holders are populated with new values)
+	 * @return returnObject
 	 */
-	public Object demarshalResponse(Message message, Object[] inputArgs) throws WebServiceException;
+	public Object demarshalResponse(Message message, Object[] signatureArgs) throws WebServiceException;
 	
     /**
-	 * This method converts Fault Message to fault java objects. Used on Client Side to extract Fault Object expected by client from message.
+	 * This method converts a Message (containing a fault) into a JAX-WS Service or WebServiceException.
+     * Used on the client.
 	 * @param message
-	 * @return
+     * @param Message
+	 * @return Throwable
 	 */
-	public Object demarshalFaultResponse(Message message) throws WebServiceException;
+	public Throwable demarshalFaultResponse(Message message) throws WebServiceException;
+    
+    /**
+     * This method creates a Message from a Throwbale input parameter. 
+     * Used on the server.
+     * @param jaxbObject
+     * @return
+     */
+    public Message marshalFaultResponse(Throwable throwable) throws WebServiceException;
+    
 	
 	
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java Thu Nov 16 20:01:48 2006
@@ -36,9 +36,15 @@
  */
 public class MethodMarshallerFactory {
 
-    private static final boolean ALT_RPCLIT = false;
-    private static final boolean ALT_DOCLIT_WRAPPED = false;
-    private static final boolean ALT_DOCLIT_BARE = false;
+    // The following flags are for testing only.
+    // The allow us to test the old implementation against the new implementation.
+    private static final boolean ALT_RPCLIT_CLIENT         = true;
+    private static final boolean ALT_DOCLIT_WRAPPED_CLIENT = true;
+    private static final boolean ALT_DOCLIT_BARE_CLIENT    = true;
+    
+    private static final boolean ALT_RPCLIT_SERVER         = true;
+    private static final boolean ALT_DOCLIT_WRAPPED_SERVER = true;
+    private static final boolean ALT_DOCLIT_BARE_SERVER    = true;
     
 	/**
 	 * Intentionally private
@@ -60,21 +66,22 @@
             ServiceDescription serviceDesc, 
             EndpointDescription endpointDesc, 
             OperationDescription operationDesc, 
-            Protocol protocol){
+            Protocol protocol, 
+            boolean isClient){  // This flag is for testing only !
 		if (style == SOAPBinding.Style.RPC) {
-            if (ALT_RPCLIT) {
+            if (ALT_RPCLIT_CLIENT && isClient || ALT_RPCLIT_SERVER && !isClient ) {
                 return new RPCLitMethodMarshaller(serviceDesc, endpointDesc, operationDesc, protocol);  
             } else {
                 return new RPCLitMethodMarshallerImpl(serviceDesc, endpointDesc, operationDesc, protocol);
             }
         } else if (paramStyle == SOAPBinding.ParameterStyle.WRAPPED){
-            if (ALT_DOCLIT_WRAPPED) {
+            if (ALT_DOCLIT_WRAPPED_CLIENT && isClient || ALT_DOCLIT_WRAPPED_SERVER && !isClient) {
                 return new DocLitWrappedMethodMarshaller(serviceDesc, endpointDesc, operationDesc, protocol);
             } else {
                 return new DocLitWrappedMethodMarshallerImpl(serviceDesc, endpointDesc, operationDesc, protocol);
             }
 		} else if (paramStyle == SOAPBinding.ParameterStyle.BARE){
-            if (ALT_DOCLIT_BARE) {
+            if (ALT_DOCLIT_BARE_CLIENT && isClient || ALT_DOCLIT_BARE_SERVER && !isClient) {
                 return new DocLitBareMethodMarshaller(serviceDesc, endpointDesc, operationDesc, protocol);
             } else {
                 return new DocLitBareMethodMarshallerImpl(serviceDesc, endpointDesc, operationDesc, protocol);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java Thu Nov 16 20:01:48 2006
@@ -24,7 +24,6 @@
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
@@ -33,7 +32,6 @@
 import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.marshaller.DocLitBareMethodMarshaller;
 import org.apache.axis2.jaxws.marshaller.MethodParameter;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.MessageException;
@@ -41,7 +39,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class DocLitBareMethodMarshallerImpl extends MethodMarshallerImpl implements DocLitBareMethodMarshaller {
+public class DocLitBareMethodMarshallerImpl extends MethodMarshallerImpl  {
     
 	private static int SIZE = 1;
 	private static Log log = LogFactory.getLog(DocLitBareMethodMarshallerImpl.class);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java Thu Nov 16 20:01:48 2006
@@ -35,25 +35,22 @@
 import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.marshaller.DocLitWrappedMethodMarshaller;
 import org.apache.axis2.jaxws.marshaller.MethodParameter;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.Protocol;
 import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
-import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
-import org.apache.axis2.jaxws.util.ClassUtils;
+import org.apache.axis2.jaxws.util.XMLRootElementUtil;
 import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class DocLitWrappedMethodMarshallerImpl extends MethodMarshallerImpl
-		implements DocLitWrappedMethodMarshaller {
+public class DocLitWrappedMethodMarshallerImpl extends MethodMarshallerImpl {
 	private static Log log = LogFactory.getLog(DocLitWrappedMethodMarshallerImpl.class);
 
 	/**
@@ -211,9 +208,9 @@
 			
             // If the wrapper class does not represent an root element, then make
             // the appropriate JAXBElement
-            if (!ClassUtils.isXmlRootElementDefined(wrapperClazz)) {
-                QName qName = new QName(wrapperTNS, wrapperLocalName);
-                wrapper = new JAXBElement(qName, wrapperClazz, wrapper);
+            if (!XMLRootElementUtil.isElementEnabled(wrapperClazz)) {
+                wrapper = XMLRootElementUtil.getElementEnabledObject(wrapperTNS, 
+                        wrapperLocalName, wrapperClazz, wrapper, false);
             }
 			Message message = createMessage(wrapper);
 
@@ -250,9 +247,12 @@
 
             // If the wrapper class does not represent an root element, then make
             // the appropriate JAXBElement
-            if (!ClassUtils.isXmlRootElementDefined(wrapperClazz)) {
-                QName qName = new QName(wrapperTNS, wrapperLocalName);
-                jaxbObject = new JAXBElement(qName, wrapperClazz, jaxbObject);
+            if (!XMLRootElementUtil.isElementEnabled(wrapperClazz)) {
+                jaxbObject = 
+                    XMLRootElementUtil.getElementEnabledObject(wrapperTNS, 
+                            wrapperLocalName,
+                            wrapperClazz, 
+                            jaxbObject, false);
             }
 			Message message = createMessage(jaxbObject);
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java Thu Nov 16 20:01:48 2006
@@ -33,8 +33,6 @@
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.JAXBIntrospector;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchema;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -63,9 +61,10 @@
 import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
 import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
-import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.message.util.MessageUtils;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.util.ClassUtils;
+import org.apache.axis2.jaxws.util.XMLRootElementUtil;
 import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
@@ -114,7 +113,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#demarshalFaultResponse(org.apache.axis2.jaxws.message.Message)
 	 */
-	public Object demarshalFaultResponse(Message message) throws WebServiceException {
+	public Throwable demarshalFaultResponse(Message message) throws WebServiceException {
 		
 		Exception exception = null;
         
@@ -153,7 +152,7 @@
                     faultQName = ((JAXBElement)obj).getName();
                     obj = ((JAXBElement)obj).getValue();
                 } else {
-                    faultQName = ClassUtils.getXmlRootElementQName(obj);
+                    faultQName = XMLRootElementUtil.getXmlRootElementQName(obj);
                 }
                 
 				// Find the JAX-WS exception using a qname match
@@ -190,6 +189,12 @@
 		try {
 			Throwable t = ClassUtils.getRootCause(throwable);
 
+			//  Get the root cause of the throwable object
+            if (log.isDebugEnabled()) {
+                log.debug("Marshal Throwable =" + throwable.getClass().getName());
+                log.debug("  message=" + throwable.getMessage());
+                log.debug("  stack=" + MessageUtils.stackToString(throwable));
+            }
 			XMLFault xmlfault = null;
 			
 			Message message = createEmptyMessage();
@@ -211,9 +216,9 @@
                 // a JAXBElement or has the XMLRootElement annotation
                 // The actual faultBean object's class is used (because
                 // the actual object may be a derived type of the formal declaration)
-            	if (!ClassUtils.isXmlRootElementDefined(faultBean.getClass())) {
-                    QName faultQName = new QName(fd.getTargetNamespace(), fd.getName());
-                    faultBean = new JAXBElement(faultQName, faultBean.getClass(), faultBean);
+            	if (!XMLRootElementUtil.isElementEnabled(faultBean.getClass())) {
+                    faultBean = XMLRootElementUtil.getElementEnabledObject(fd.getTargetNamespace(), fd.getName(),
+                            faultBean.getClass(), faultBean, false);
                 }
             	detailBlocks[0] = createJAXBBlock(faultBean, context);
                 text = t.getMessage();
@@ -655,11 +660,6 @@
 		
 	}
 	
-	protected Block createJAXBBlock(OMElement om, JAXBBlockContext context)throws  XMLStreamException, MessageException {
-		JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
-		return factory.createFrom(om,context,null);
-		
-	}
 	
 	protected String readXMLTypeName(Class jaxbClazz){
 		XmlType type = (XmlType)jaxbClazz.getAnnotation(XmlType.class);
@@ -803,7 +803,7 @@
 			if (log.isDebugEnabled()) {
 	            log.debug("Attempting to create Block");
 	        }
-			if(ClassUtils.isXmlRootElementDefined(objectType)){
+			if(XMLRootElementUtil.isElementEnabled(objectType)){
 				block = createJAXBBlock(object, ctx);
 			}
 			else{

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java Thu Nov 16 20:01:48 2006
@@ -18,21 +18,26 @@
  */
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
-import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.Set;
+
 import javax.xml.ws.WebServiceException;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
-import org.apache.axis2.jaxws.marshaller.impl.MethodMarshallerImpl;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 
+
 public class DocLitBareMethodMarshaller implements MethodMarshaller {
 
     private static Log log = LogFactory.getLog(DocLitBareMethodMarshaller.class);
@@ -50,12 +55,42 @@
         this.protocol = protocol;
     }
 
-    public Object demarshalResponse(Message message, Object[] inputArgs)
+    public Object demarshalResponse(Message message, Object[] signatureArgs)
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:return ... >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element in the message
+            //   2) The data blocks are located underneath the operation element. 
+            //   3) The name of the data blocks (m:param) are defined by the schema.
+            //      (SOAP indicates that the name of the element is not important, but
+            //      for document processing, we will assume that the name corresponds to 
+            //      a schema root element)
+            //   4) The type of the data block is defined by schema; thus in most cases
+            //      an xsi:type will not be present
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+              
+            // Get the return value.
+            Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+            Object returnValue = null;
+            if (returnType != void.class) {
+                returnValue = MethodMarshallerUtils.getReturnValue(packages, message);
+            }
+            
+            // Unmarshall the ParamValues from the Message
+            List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds, message, packages, false, false);
+            
+            // Populate the response Holders
+            MethodMarshallerUtils.updateResponseSignatureArgs(pds, pvList, signatureArgs);
+            
+            return returnValue;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
@@ -65,29 +100,125 @@
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:param .. >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element under the body.
+            //   2) The data blocks are located underneath the body.  
+            //   3) The name of the data blocks (m:param) are defined by the schema
+            //   4) The type of the data block (data:foo) is defined by schema (and probably
+            //      is not present in the message
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+            
+            
+            // Unmarshal the ParamValues from the message
+            List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds, message, packages, true, false);
+            
+            // Build the signature arguments
+            Object[] sigArguments = MethodMarshallerUtils.createRequestSignatureArgs(pds, pvList);
+            
+            return sigArguments;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Message marshalResponse(Object returnObject, Object[] holderObjects)
+    public Message marshalResponse(Object returnObject, Object[] signatureArgs)
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:return ... >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element in the message
+            //   2) The data blocks are located underneath the operation element. 
+            //   3) The name of the data blocks (m:param) are defined by the schema.
+            //      (SOAP indicates that the name of the element is not important, but
+            //      for document processing, we will assume that the name corresponds to 
+            //      a schema root element)
+            //   4) The type of the data block is defined by schema; thus in most cases
+            //      an xsi:type will not be present
+            
+            // Get the operation information
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+            
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // Put the return object onto the message
+            Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+            if (returnType != void.class) {
+                MethodMarshallerUtils.toMessage(returnObject, returnType,
+                        operationDesc.getResultTargetNamespace(),
+                        operationDesc.getResultName(), packages, m, 
+                        false); // don't force xsi:type for doc/lit
+            }
+            
+            // Convert the holder objects into a list of JAXB objects for marshalling
+            List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds, 
+                    signatureArgs, 
+                    false, // output
+                    false, // use name (element name) not wsd:part name
+                    false); // don't force xsi:type for doc/lit
+
+            // Put values onto the message
+            MethodMarshallerUtils.toMessage(pvList, m, packages);
+            
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Message marshalRequest(Object[] object) throws WebServiceException {
+    public Message marshalRequest(Object[] signatureArguments) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:param .. >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element under the body.
+            //   2) The data blocks are located underneath the body.  
+            //   3) The name of the data blocks (m:param) are defined by the schema
+            //   4) The type of the data block (data:foo) is defined by schema (and probably
+            //      is not present in the message
+            
+            
+            // Get the operation information
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+            
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // The input object represent the signature arguments.
+            // Signature arguments are both holders and non-holders
+            // Convert the signature into a list of JAXB objects for marshalling
+            List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds, 
+                    signatureArguments, 
+                    true,  // input
+                    false, // use name (element name) not wsd:part name
+                    false); // don't force xsi:type for doc/lit
+            
+            // Put values onto the message
+            MethodMarshallerUtils.toMessage(pvList, m, packages);
+            
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
@@ -96,18 +227,27 @@
     public Message marshalFaultResponse(Throwable throwable) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // Put the fault onto the message
+            MethodMarshallerUtils.marshalFaultResponse(throwable, 
+                    operationDesc, 
+                    endpointDesc.getPackages(), 
+                    m, 
+                    false); // don't force xsi:type for doc/lit
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Object demarshalFaultResponse(Message message) throws WebServiceException {
+    public Throwable demarshalFaultResponse(Message message) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            Throwable t = MethodMarshallerUtils.demarshalFaultResponse(operationDesc, endpointDesc.getPackages(), message, false);
+            return t;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?view=diff&rev=476045&r1=476044&r2=476045
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java Thu Nov 16 20:01:48 2006
@@ -18,17 +18,33 @@
  */
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
-import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import javax.jws.WebParam.Mode;
+import javax.xml.bind.JAXBElement;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.OperationDescriptionJava;
+import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
-import org.apache.axis2.jaxws.marshaller.impl.MethodMarshallerImpl;
+import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
+import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.util.XMLRootElementUtil;
+import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -50,12 +66,104 @@
         this.protocol = protocol;
     }
 
-    public Object demarshalResponse(Message message, Object[] inputArgs)
+    public Object demarshalResponse(Message message, Object[] signatureArgs)
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:return ... >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element in the message
+            //   2) The data blocks are located underneath the operation element. 
+            //   3) The name of the data blocks (m:param) are defined by the schema.
+            //      (SOAP indicates that the name of the element is not important, but
+            //      for document processing, we will assume that the name corresponds to 
+            //      a schema root element)
+            //   4) The type of the data block is defined by schema; thus in most cases
+            //      an xsi:type will not be present
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+            
+            // Determine if a returnValue is expected.
+            // The return value may be an child element
+            // The wrapper element 
+            // or null
+            Object returnValue = null;
+            Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+            boolean isChildReturn = (operationDesc instanceof OperationDescriptionJava) &&
+                ((OperationDescriptionJava) operationDesc).isWebResultAnnotationSpecified();
+            boolean isNoReturn = (returnType == void.class);
+            
+            // In usage=WRAPPED, there will be a single JAXB block inside the body.
+            // Get this block
+            JAXBBlockContext blockContext = new JAXBBlockContext(packages);        
+            JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+            Block block = message.getBodyBlock(0, blockContext, factory);
+            Object wrapperObject = block.getBusinessObject(true);
+            
+            // The child elements are within the object that 
+            // represents the type
+            if (wrapperObject instanceof JAXBElement) {
+                wrapperObject = ((JAXBElement) wrapperObject).getValue();
+            }
+            
+            // Use the wrapper tool to get the child objects.
+            JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+            
+            // Get the list of names for the output parameters
+            List<String> names = new ArrayList<String>();
+            List<ParameterDescription> pdList = new ArrayList<ParameterDescription>();
+            for (int i=0; i<pds.length; i++) {
+                ParameterDescription pd = pds[i];
+                if (pd.getMode() == Mode.OUT ||
+                        pd.getMode() == Mode.INOUT) {
+                    names.add(pd.getParameterName());
+                    pdList.add(pd);
+                }
+            }
+            
+            // The return name is added as the last name
+            if (isChildReturn && !isNoReturn) {
+                names.add(operationDesc.getResultPartName());
+            }
+            
+            // Get the child objects
+            Object[] objects = wrapperTool.unWrap(wrapperObject, names);
+            
+            // Now create a list of paramValues so that we can populate the signature
+            List<PDElement> pvList = new ArrayList<PDElement>();
+            for (int i=0; i<pdList.size(); i++) {
+                ParameterDescription pd = pdList.get(i);
+                Object value = objects[i];
+                // The object in the PDElement must be an element
+                if (!XMLRootElementUtil.isElementEnabled(pd.getParameterActualType())) {
+                    value = XMLRootElementUtil.getElementEnabledObject(pd.getTargetNamespace(),
+                            pd.getPartName(), 
+                            pd.getParameterActualType(), 
+                            value,
+                            false); // don't force xsi:type for doc/lit
+     
+                }
+                pvList.add(new PDElement(pd, value));
+            }
+            
+            // Populate the response Holders in the signature
+            MethodMarshallerUtils.updateResponseSignatureArgs(pds, pvList, signatureArgs);
+            
+            // Now get the return value
+            if (isNoReturn) {
+                returnValue = null;
+            } else if (isChildReturn) {
+                returnValue = objects[objects.length-1];
+            } else {
+                returnValue = wrapperObject;
+            }
+            
+            return returnValue;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
@@ -65,29 +173,251 @@
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:param .. >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element under the body.
+            //   2) The data blocks are located underneath the body.  
+            //   3) The name of the data blocks (m:param) are defined by the schema
+            //   4) The type of the data block (data:foo) is defined by schema (and probably
+            //      is not present in the message
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            Set<Package> packages = endpointDesc.getPackages();
+                        
+            // In usage=WRAPPED, there will be a single JAXB block inside the body.
+            // Get this block
+            JAXBBlockContext blockContext = new JAXBBlockContext(packages);        
+            JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+            Block block = message.getBodyBlock(0, blockContext, factory);
+            Object wrapperObject = block.getBusinessObject(true);
+            
+            // The child elements are within the object that 
+            // represents the type
+            if (wrapperObject instanceof JAXBElement) {
+                wrapperObject = ((JAXBElement) wrapperObject).getValue();
+            }
+            
+            // Use the wrapper tool to get the child objects.
+            JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+            
+            // Get the list of names for the input parameters
+            List<String> names = new ArrayList<String>();
+            List<ParameterDescription> pdList = new ArrayList<ParameterDescription>();
+            for (int i=0; i<pds.length; i++) {
+                ParameterDescription pd = pds[i];
+                if (pd.getMode() == Mode.IN ||
+                        pd.getMode() == Mode.INOUT) {
+                    names.add(pd.getParameterName());
+                    pdList.add(pd);
+                }
+                      
+            }
+            
+            // Get the child objects
+            Object[] objects = wrapperTool.unWrap(wrapperObject, names);
+            
+            // Now create a list of paramValues 
+            List<PDElement> pvList = new ArrayList<PDElement>();
+            for (int i=0; i<pdList.size(); i++) {
+                ParameterDescription pd = pdList.get(i);
+                Object value = objects[i];
+                // The object in the PDElement must be an element
+                if (!XMLRootElementUtil.isElementEnabled(pd.getParameterActualType())) {
+                    value = XMLRootElementUtil.getElementEnabledObject(pd.getTargetNamespace(),
+                            pd.getPartName(), 
+                            pd.getParameterActualType(), 
+                            value, 
+                            false);  // don't force xsi:type for doc/lit
+     
+                }
+                pvList.add(new PDElement(pd, value));
+            }
+             
+            // Build the signature arguments
+            Object[] sigArguments = MethodMarshallerUtils.createRequestSignatureArgs(pds, pvList);
+            
+            return sigArguments;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Message marshalResponse(Object returnObject, Object[] holderObjects)
+    public Message marshalResponse(Object returnObject, Object[] signatureArgs)
             throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:return ... >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element in the message
+            //   2) The data blocks are located underneath the operation element. 
+            //   3) The name of the data blocks (m:param) are defined by the schema.
+            //      (SOAP indicates that the name of the element is not important, but
+            //      for document processing, we will assume that the name corresponds to 
+            //      a schema root element)
+            //   4) The type of the data block is defined by schema; thus in most cases
+            //      an xsi:type will not be present
+            
+            // Get the operation information
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // In usage=WRAPPED, there will be a single block in the body.
+            // The signatureArguments represent the child elements of that block
+            // The first step is to convert the signature arguments into a list
+            // of parameter values
+            List<PDElement> pvList = 
+                MethodMarshallerUtils.getPDElements(pds,
+                        signatureArgs, 
+                        false,  // output
+                        true,   // use partNames (which are child names)
+                        false);  // don't force xis:type for doc/lit
+
+            // Now we want to create a single JAXB element that contains the 
+            // ParameterValues.  We will use the wrapper tool to do this.
+            // Create the inputs to the wrapper tool
+            ArrayList<String> nameList = new ArrayList<String>();
+            Map<String, Object> objectList = new WeakHashMap<String, Object>();
+            
+            for(PDElement pv:pvList) {
+                String name = pv.getParam().getParameterName();
+            
+                // The object list contains type rendered objects
+                Object value = pv.getElementValue();
+                if (value instanceof JAXBElement) {
+                    value = ((JAXBElement) value).getValue();
+                }
+                nameList.add(name);
+                objectList.put(name, value);
+            }
+            
+            // Add the return object to the nameList and objectList
+            Class returnType = MethodMarshallerUtils.getActualReturnType(operationDesc);
+            if (returnType != void.class) {
+                String name = operationDesc.getResultName();
+                nameList.add(name);
+                objectList.put(name, returnObject);
+            }
+            
+            // Now create the single JAXB element
+            Class cls = MethodMarshallerUtils.loadClass(operationDesc.getResponseWrapperClassName());
+            JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+            Object object  = wrapperTool.wrap(cls, nameList, objectList);
+            
+            // Make sure object can be rendered as an element
+            if (!XMLRootElementUtil.isElementEnabled(cls)) {
+                object = XMLRootElementUtil.getElementEnabledObject(
+                        operationDesc.getResponseWrapperTargetNamespace(), 
+                        operationDesc.getResponseWrapperLocalName(), 
+                        cls, 
+                        object, 
+                        false);  // don't force xsitype for doc/lit
+            }
+            
+            
+            // Put the object into the message
+            JAXBBlockFactory factory = 
+                (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+            
+            Block block = factory.createFrom(object, 
+                    new JAXBBlockContext(endpointDesc.getPackages()), 
+                    null);  // The factory will get the qname from the value
+            m.setBodyBlock(0, block);
+            
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Message marshalRequest(Object[] object) throws WebServiceException {
+    public Message marshalRequest(Object[] signatureArguments) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Sample Document message
+            // ..
+            // <soapenv:body>
+            //    <m:param .. >...</m:param>
+            // </soapenv:body>
+            //
+            // Important points.
+            //   1) There is no operation element under the body.
+            //   2) The data blocks are located underneath the body.  
+            //   3) The name of the data blocks (m:param) are defined by the schema
+            //   4) The type of the data block (data:foo) is defined by schema (and probably
+            //      is not present in the message
+            
+            
+            // Get the operation information
+            ParameterDescription[] pds =operationDesc.getParameterDescriptions();
+            
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // In usage=WRAPPED, there will be a single block in the body.
+            // The signatureArguments represent the child elements of that block
+            // The first step is to convert the signature arguments into list
+            // of parameter values
+            List<PDElement> pvList = MethodMarshallerUtils.getPDElements(pds, 
+                    signatureArguments, 
+                    true,   // input
+                    true,   // use partName (which are the child element names)
+                    false); // we don't force xsi:type for doc/lit
+            
+            // Now we want to create a single JAXB element that contains the 
+            // ParameterValues.  We will use the wrapper tool to do this.
+            // Create the inputs to the wrapper tool
+            ArrayList<String> nameList = new ArrayList<String>();
+            Map<String, Object> objectList = new WeakHashMap<String, Object>();
+            
+            for(PDElement pv:pvList){
+                String name = pv.getParam().getParameterName();
+            
+                // The object list contains type rendered objects
+                Object value = pv.getElementValue();
+                if (value instanceof JAXBElement) {
+                    value = ((JAXBElement) value).getValue();
+                }
+                nameList.add(name);
+                objectList.put(name, value);
+            }
+            
+            // Now create the single JAXB element 
+            Class cls = MethodMarshallerUtils.loadClass(operationDesc.getRequestWrapperClassName());
+            JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+            Object object  = wrapperTool.wrap(cls, nameList, objectList);
+            
+            // Make sure object can be rendered as an element
+            if (!XMLRootElementUtil.isElementEnabled(cls)) {
+                object = XMLRootElementUtil.getElementEnabledObject(
+                        operationDesc.getRequestWrapperTargetNamespace(), 
+                        operationDesc.getRequestWrapperLocalName(), 
+                        cls, 
+                        object, 
+                        false);  // for doc/lit we don't want to force xsi:type
+            }
+            
+            // Put the object into the message
+            JAXBBlockFactory factory = 
+                (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+            
+            Block block = factory.createFrom(object, 
+                    new JAXBBlockContext(endpointDesc.getPackages()), 
+                    null);  // The factory will get the qname from the value
+            m.setBodyBlock(0, block);
+            
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
@@ -96,18 +426,30 @@
     public Message marshalFaultResponse(Throwable throwable) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            // Create the message 
+            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
+            Message m = mf.create(protocol);
+            
+            // Put the fault onto the message
+            MethodMarshallerUtils.marshalFaultResponse(throwable, 
+                    operationDesc, 
+                    endpointDesc.getPackages(), 
+                    m, 
+                    false); // don't force xsi:type for doc/lit
+            return m;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
 
-    public Object demarshalFaultResponse(Message message) throws WebServiceException {
+    public Throwable demarshalFaultResponse(Message message) throws WebServiceException {
         // Note all exceptions are caught and rethrown with a WebServiceException
         try {
-            // TODO Add Real Code
-            throw new UnsupportedOperationException();
+            Throwable t = MethodMarshallerUtils.demarshalFaultResponse(operationDesc, 
+                    endpointDesc.getPackages(), 
+                    message, 
+                    false);
+            return t;
         } catch(Exception e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org