axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r453977 [1/2] - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/factory/ src/org/apache/axis2/jaxws/client/proxy/ src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/jaxws/i18n/ src/org/apache/axis...
Date Sat, 07 Oct 2006 18:17:12 GMT
Author: barrettj
Date: Sat Oct  7 11:17:10 2006
New Revision: 453977

URL: http://svn.apache.org/viewvc?view=rev&rev=453977
Log:
AXIS2-1321 AXIS2-1322
Patch submitted by Nikhil Thaker

Added:
    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/marshaller/
    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
    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/MethodParameter.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/
    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/
    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
Removed:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/factory/DescriptorFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/factory/ProxyHandlerFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/BaseProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/DocLitProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/RPCLitProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/Mapper.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/MapperImpl.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.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/registry/FactoryRegistry.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/spi/ServiceDelegate.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/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/BareTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/WrapTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/nonwrap/DocLitNonWrapPortTypeImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/nonwrap/META-INF/services.xml
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java

Added: 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=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,412 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.client.proxy;
+
+import java.beans.IntrospectionException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.concurrent.Future;
+
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.jaxws.AxisController;
+import org.apache.axis2.jaxws.BindingProvider;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.InvocationContextFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.core.controller.AxisInvocationController;
+import org.apache.axis2.jaxws.core.controller.InvocationController;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.handler.PortData;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
+import org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory;
+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.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+// import com.sun.xml.bind.v2.runtime.reflect.Lister;
+
+/**
+ * ProxyHandler is the java.lang.reflect.InvocationHandler implementation.
+ * When jaxws client calls the method on proxy object that it gets using the getPort
+ * ServiceDelegate api, the Inovke method on ProxyHandler is Invoked.
+ * ProxyHandler uses EndpointInterfaceDescriptor and finds out if 
+ * 1) The client call is Document Literal or Rpc Literal
+ * 2) The WSDL is wrapped or unWrapped. 
+ * 
+ * ProxyHandler then reads OperationDescription using Method name called by Client
+ * From OperationDescription it does the following 
+ * 1) if the wsdl isWrapped() reads RequestWrapper Class and responseWrapperClass
+ * 2) then reads the webParams for the Operation.
+ * 
+ * isWrapped() = true  and DocLiteral then
+ * ProxyHandler then uses WrapperTool to create Request that is a Wrapped JAXBObject.
+ * Creates JAXBBlock using JAXBBlockFactory
+ * Creates MessageContext->Message and sets JAXBBlock to xmlPart as RequestMsgCtx in InvocationContext.
+ * Makes call to InvocationController.
+ * Reads ResponseMsgCtx ->MessageCtx->Message->XMLPart.
+ * Converts that to JAXBlock using JAXBBlockFactory and returns the BO from this JAXBBlock.
+ * 
+ * isWrapped() != true and DocLiteral then
+ * ProxyHandler creates the JAXBBlock for the input request creates a 
+ * MessageContext that is then used by IbvocationController to invoke.
+ * Response is read and return object is derived using @Webresult annotation.
+ * A JAXBBlock is created from the Response and the BO from JAXBBlock is
+ * returned.  
+ * 
+ * RPCLiteral 
+ * TBD
+ * 
+ */
+
+public class JAXWSProxyHandler extends BindingProvider implements
+		InvocationHandler {
+	private static Log log = LogFactory.getLog(JAXWSProxyHandler.class);
+
+	//Reference to ServiceDelegate instance that was used to create the Proxy
+	private ServiceDelegate delegate = null;
+	protected ServiceDescription serviceDesc = null;
+	protected EndpointDescription endpointDesc = null;
+	protected OperationDescription operationDesc = null;
+	protected MethodMarshaller methodMarshaller = null;
+	private PortData port = null;
+	private Class seiClazz = null;
+	private Method method = null;
+	
+	public JAXWSProxyHandler(ServiceDelegate delegate, Class seiClazz, PortData port) {
+		super();
+		this.delegate = delegate;
+		this.seiClazz = seiClazz;
+		this.port = port;
+		this.serviceDesc=delegate.getServiceDescription();
+//		FIXME: This probably needs to be more robust; can there be > 1 endpoints; if so, how choose which one?
+		this.endpointDesc = serviceDesc.getEndpointDescription(seiClazz)[0];
+		initRequestContext();
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+	 * 
+	 * Invoke method checks to see if BindingProvider method was invoked by client if yes, it uses reflection and invokes the BindingProvider method.
+	 * If SEI method was called then it delegates to InvokeSEIMethod().
+	 */
+	public Object invoke(Object proxy, Method method, Object[] args)
+			throws Throwable {
+		if (log.isDebugEnabled()) {
+            log.debug("Attemping to invoke Method: " +method.getName());
+        }
+        
+		this.method = method;
+		
+		if(!isValidMethodCall(method)){
+			throw ExceptionFactory.makeWebServiceException(Messages.getMessage("proxyErr1",method.getName(), seiClazz.getName()));
+		}
+		
+		if(!isPublic(method)){
+			throw ExceptionFactory.makeWebServiceException("Invalid Method Call, Method "+method.getName() + " not a public method"); 
+		}
+		
+		if(isBindingProviderInvoked(method)){
+			if (log.isDebugEnabled()) {
+	            log.debug("Invoking method on Binding Provider");
+	        }
+			try{
+				return method.invoke(this, args);
+			}catch(Throwable e){
+				throw ExceptionFactory.makeMessageException(e);
+			}
+			
+		}
+		else{
+			operationDesc = endpointDesc.getEndpointInterfaceDescription().getOperation(method);
+			if(isMethodExcluded()){
+				throw ExceptionFactory.makeWebServiceException("Invalid Method Call, Method "+method.getName() + " has been excluded using @webMethod annotation");
+			}
+			try{
+				return InvokeSEIMethod(method, args);
+			}catch(Throwable e){
+				throw ExceptionFactory.makeWebServiceException(e);
+			}
+		}
+	}
+	
+	/**
+	 * InvokeSEIMethod invokes Axis engine using methods on InvocationController. Create request Invocation context, instantiates AxisInvocationController and 
+	 * runs invoke.
+	 * 
+	 */
+	private Object InvokeSEIMethod(Method method, Object[] args)throws Throwable{
+		if (log.isDebugEnabled()) {
+            log.debug("Attempting to Invoke SEI Method "+ method.getName());
+        }
+		initialize();
+		InvocationContext requestIC = InvocationContextFactory.createInvocationContext(null);
+		MessageContext requestContext = createRequest(method, args);
+		//Enable MTOM on the Message if the property was
+        //set on the SOAPBinding.
+        Binding bnd = getBinding();
+        if (bnd != null && bnd instanceof SOAPBinding) {
+            javax.xml.ws.soap.SOAPBinding soapBnd = (javax.xml.ws.soap.SOAPBinding) bnd;
+            if (soapBnd.isMTOMEnabled()) {
+                Message requestMsg = requestContext.getMessage();
+                requestMsg.setMTOMEnabled(true);
+            }
+        }
+        requestContext.setOperationDescription(operationDesc);
+		requestIC.setRequestMessageContext(requestContext);
+		InvocationController controller = new AxisInvocationController();
+		requestIC.setServiceClient(delegate.getServiceClient(port.getPortName()));
+		
+		//check if the call is OneWay, Async or Sync
+		//if(operationDesc.isOneWay() || method.getReturnType().getName().equals("void")){
+		if(operationDesc.isOneWay()){
+			if(log.isDebugEnabled()){
+				log.debug("OneWay Call");
+			}
+			controller.invokeOneWay(requestIC);
+		}
+		
+		if(method.getReturnType().isAssignableFrom(Future.class)){
+			if(log.isDebugEnabled()){
+				log.debug("Async Callback");
+			}
+			//Get AsyncHandler from Objects and sent that to InvokeAsync
+			AsyncHandler asyncHandler = null;
+			for(Object obj:args){
+				if(obj !=null && AsyncHandler.class.isAssignableFrom(obj.getClass())){
+					asyncHandler = (AsyncHandler)obj;
+					break;
+				}
+			}
+			if(asyncHandler == null){
+				throw ExceptionFactory.makeWebServiceException("AynchHandler null for Async callback, Invalid AsyncHandler callback Object");
+			}
+			AsyncListener listener = createProxyListener(args);
+			requestIC.setAsyncListener(listener);
+			requestIC.setExecutor(delegate.getExecutor());
+			return controller.invokeAsync(requestIC, asyncHandler);
+		}
+		
+		if(method.getReturnType().isAssignableFrom(Response.class)){
+			if(log.isDebugEnabled()){
+				log.debug("Async Polling");
+			}
+			AsyncListener listener = createProxyListener(args);
+			requestIC.setAsyncListener(listener);
+			requestIC.setExecutor(delegate.getExecutor());
+			return controller.invokeAsync(requestIC);
+		}
+		
+		if(!operationDesc.isOneWay()){
+			InvocationContext responseIC = controller.invoke(requestIC);
+		
+			MessageContext responseContext = responseIC.getResponseMessageContext();
+			Object responseObj = createResponse(method, args, responseContext);
+			return responseObj;
+		}
+		return null;
+	}
+	
+	private AsyncListener createProxyListener(Object[] args){
+		ProxyAsyncListener listener = new ProxyAsyncListener();
+		listener.setHandler(this);
+		listener.setInputArgs(args);
+		return listener;
+	}
+	
+	protected boolean isAsync(){
+		String methodName = method.getName();
+		Class returnType = method.getReturnType();
+		return methodName.endsWith("Async") && (returnType.isAssignableFrom(Response.class) || returnType.isAssignableFrom(Future.class));
+	}
+	/**
+	 * Create request context for the method call. This request context will be used by InvocationController to route the method call to axis engine.
+	 * @param method
+	 * @param args
+	 * @return
+	 */
+	protected MessageContext createRequest(Method method, Object[] args) throws Throwable{
+		if (log.isDebugEnabled()) {
+            log.debug("Converting objects to Message");
+        }
+		Message message = methodMarshaller.marshalRequest(args);
+		
+		if (log.isDebugEnabled()) {
+            log.debug("Objects converted to Message");
+        }
+		MessageContext request = new MessageContext();
+		request.setMessage(message);
+		request.getProperties().putAll(getRequestContext());
+		if (log.isDebugEnabled()) {
+            log.debug("Request Created");
+        }
+		return request;	
+	}
+	
+	/**
+	 * Creates response context for the method call. This response context will be used to create response result to the client call.
+	 * @param method
+	 * @param responseContext
+	 * @return
+	 */
+	protected Object createResponse(Method method, Object[] args, MessageContext responseContext)throws Throwable{
+		Message responseMsg = responseContext.getMessage();
+		if (log.isDebugEnabled()) {
+            log.debug("Converting Message to Response Object");
+        }
+		Object object = methodMarshaller.demarshalResponse(responseMsg, args);
+		if (log.isDebugEnabled()) {
+            log.debug("Message Converted to response Object");
+        }
+		return object;
+	}
+	
+	private boolean isBindingProviderInvoked(Method method){
+		Class methodsClass = method.getDeclaringClass();
+		return (seiClazz == methodsClass)?false:true;
+	}
+	
+	private boolean isValidMethodCall(Method method){
+		Class clazz = method.getDeclaringClass();
+		if(clazz == javax.xml.ws.BindingProvider.class || clazz == seiClazz){
+			return true;
+		}
+		return false;
+	}
+	
+	public void setDelegate(ServiceDelegate delegate) {
+		this.delegate = delegate;
+	}
+	
+	protected void initRequestContext() {
+		String soapAddress = null;
+		String soapAction = null;
+		String endPointAddress = port.getEndpointAddress();
+		WSDLWrapper wsdl = delegate.getServiceDescription().getWSDLWrapper();
+		QName serviceName = delegate.getServiceName();
+		QName portName = port.getPortName();
+		if (wsdl != null) {
+			soapAddress = wsdl.getSOAPAddress(serviceName, portName);
+			soapAction = wsdl.getSOAPAction(serviceName, portName);
+		}
+		super.initRequestContext(endPointAddress, soapAddress, soapAction);
+	}
+
+	protected ServiceDelegate getDelegate() {
+		return delegate;
+	}
+	
+	private boolean isPublic(Method method){
+		return Modifier.isPublic(method.getModifiers());
+	}
+	
+	private boolean isMethodExcluded(){
+		return operationDesc.isWebMethodExcluded();
+	}
+
+	public PortData getPort() {
+		return port;
+	}
+
+	public void setPort(PortData port) {
+		this.port = port;
+	}
+
+	public Class getSeiClazz() {
+		return seiClazz;
+	}
+
+	public void setSeiClazz(Class seiClazz) {
+		this.seiClazz = seiClazz;
+	}
+	private void initialize(){
+		SOAPBinding.Style styleOnSEI = endpointDesc.getEndpointInterfaceDescription().getSoapBindingStyle();
+		SOAPBinding.Style styleOnMethod = operationDesc.getSoapBindingStyle();
+		if(styleOnMethod!=null && styleOnSEI!=styleOnMethod){
+			throw ExceptionFactory.makeWebServiceException(Messages.getMessage("proxyErr2"));
+		}
+		
+		MethodMarshallerFactory cf = (MethodMarshallerFactory) FactoryRegistry.getFactory(MethodMarshallerFactory.class);
+		if(styleOnSEI == SOAPBinding.Style.DOCUMENT){
+			methodMarshaller = createDocLitMethodMarshaller(cf);
+		}
+		if(styleOnSEI == SOAPBinding.Style.RPC){
+			methodMarshaller = createRPCLitMethodMarshaller(cf);
+			
+		}
+	
+	}
+	private MethodMarshaller createDocLitMethodMarshaller(MethodMarshallerFactory cf){
+		ParameterStyle parameterStyle = null;
+		if(isDocLitBare()){
+			parameterStyle = SOAPBinding.ParameterStyle.BARE;
+		}
+		if(isDocLitWrapped()){
+			parameterStyle = SOAPBinding.ParameterStyle.WRAPPED;
+		}
+		//FIXME: The protocol should actually come from the binding information included in
+	    // either the WSDL or an annotation.
+		return cf.createDocLitMethodMarshaller(parameterStyle, serviceDesc, endpointDesc, operationDesc, Protocol.soap11);
+	}
+	
+	private MethodMarshaller createRPCLitMethodMarshaller(MethodMarshallerFactory cf){
+		return cf.createDocLitMethodMarshaller(null, serviceDesc, endpointDesc, operationDesc, Protocol.soap11);
+	}
+	protected boolean isDocLitBare(){
+		SOAPBinding.ParameterStyle methodParamStyle = operationDesc.getSoapBindingParameterStyle();
+		if(methodParamStyle!=null){
+			return methodParamStyle == SOAPBinding.ParameterStyle.BARE;
+		}
+		else{
+			SOAPBinding.ParameterStyle SEIParamStyle = endpointDesc.getEndpointInterfaceDescription().getSoapBindingParameterStyle();
+			return SEIParamStyle == SOAPBinding.ParameterStyle.BARE;
+		}
+	}
+	
+	protected boolean isDocLitWrapped(){
+		SOAPBinding.ParameterStyle methodParamStyle = operationDesc.getSoapBindingParameterStyle();
+		if(methodParamStyle!=null){
+			return methodParamStyle == SOAPBinding.ParameterStyle.WRAPPED;
+		}
+		else{
+		SOAPBinding.ParameterStyle SEIParamStyle = endpointDesc.getEndpointInterfaceDescription().getSoapBindingParameterStyle();
+		return SEIParamStyle == SOAPBinding.ParameterStyle.WRAPPED;
+		}
+	}
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java?view=diff&rev=453977&r1=453976&r2=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java Sat Oct  7 11:17:10 2006
@@ -16,13 +16,6 @@
  */
 package org.apache.axis2.jaxws.client.proxy;
 
-import java.util.concurrent.ExecutionException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPBody;
-import javax.xml.ws.WebServiceException;
-
-import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.jaxws.AxisCallback;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
@@ -37,18 +30,23 @@
  */
 public class ProxyAsyncListener extends AsyncListener {
 
-	BaseProxyHandler handler = null;
+	JAXWSProxyHandler handler = null;
+	Object[] inputArgs = null;
 	public ProxyAsyncListener() {
 		super();
 	}
-
-	public BaseProxyHandler getHandler() {
+	
+	public JAXWSProxyHandler getHandler() {
 		return handler;
 	}
 
-	public void setHandler(BaseProxyHandler handler) {
+	public void setHandler(JAXWSProxyHandler handler) {
 		this.handler = handler;
 	}
+	
+	public void setInputArgs(Object[] inputArgs){
+		this.inputArgs = inputArgs;
+	}
 
 	/**
 	 * @param cb
@@ -62,8 +60,8 @@
 		 
 		 try{
 			 //I will delegate the request to create respose to proxyHandler since it has all the logic written to create response for Sync and oneWay.
-			  return handler.createResponse(null, mc);
-		 }catch(Exception e){
+			  return handler.createResponse(null,inputArgs, mc);
+		 }catch(Throwable e){
 			throw ExceptionFactory.makeWebServiceException(e);
 		 }
 	 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java?view=diff&rev=453977&r1=453976&r2=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java Sat Oct  7 11:17:10 2006
@@ -26,6 +26,7 @@
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebResult;
+import javax.jws.WebParam.Mode;
 import javax.jws.soap.SOAPBinding;
 import javax.xml.namespace.QName;
 import javax.xml.ws.RequestWrapper;
@@ -138,6 +139,7 @@
     // TODO: Should WebParam annotation be moved to the ParameterDescription?
     private WebParam[]          webParamAnnotations;
     private String[]            webParamNames;
+    private Mode[]				webParamMode;
     private String[]            webParamTNS;
 
     
@@ -439,14 +441,7 @@
             ArrayList<String> buildNames = new ArrayList<String>();
             WebParam[] webParams = getWebParam();
             for (WebParam currentParam:webParams) {
-                // TODO: Is skipping param names of "asyncHandler" correct?  This came from original ProxyDescription class and ProxyTest fails without this code
-                //       Due to code in DocLitProxyHandler.getParamValues() which does not add values for AsyncHandler objects.
-                //       It probably DOES need to be skipped, albeit more robustly (check that the type of the param is javax.xml.ws.AsyncHandler also)
-                //       The reason is that the handler is part of the JAX-WS async callback programming model; it is NOT part of the formal params
-                //       to the actual method and therefore is NOT part of the JAXB request wrapper
-                if(!currentParam.name().equals("asyncHandler")){
                     buildNames.add(currentParam.name());
-                }
             }
             webParamNames = buildNames.toArray(new String[0]);
         }
@@ -459,20 +454,24 @@
             ArrayList<String> buildNames = new ArrayList<String>();
             WebParam[] webParams = getWebParam();
             for (WebParam currentParam:webParams) {
-                // TODO: Is skipping param names of "asyncHandler" correct?  This came from original ProxyDescription class and ProxyTest fails without this code
-                //       Due to code in DocLitProxyHandler.getParamValues() which does not add values for AsyncHandler objects.
-                //       It probably DOES need to be skipped, albeit more robustly (check that the type of the param is javax.xml.ws.AsyncHandler also)
-                //       The reason is that the handler is part of the JAX-WS async callback programming model; it is NOT part of the formal params
-                //       to the actual method and therefore is NOT part of the JAXB request wrapper
-                if(!currentParam.name().equals("asyncHandler")){
-                    buildNames.add(currentParam.targetNamespace());
-                }
+            	buildNames.add(currentParam.targetNamespace());
             }
             webParamTNS = buildNames.toArray(new String[0]);
         }
         return webParamTNS;
     }
              
+    public Mode[] getWebParamModes(){
+    	if(webParamMode == null){
+    		ArrayList<Mode> buildModes = new ArrayList<Mode>();
+    		WebParam[] webParams = getWebParam();
+    		for (WebParam currentParam:webParams){
+                buildModes.add(currentParam.mode());
+    		}
+    		 webParamMode = buildModes.toArray(new Mode[0]);
+    	}
+    	return webParamMode;
+    }
     public String getWebParamTNS(String name){
        WebParam[] webParams = getWebParam();
        for (WebParam currentParam:webParams){
@@ -584,4 +583,13 @@
         }
         return onewayIsOneway.booleanValue();   
     }
+    
+    public boolean isWebMethodExcluded(){
+		WebMethod webMethod = getWebMethod();
+		if(webMethod == null){
+			return false;
+		}
+		
+		return webMethod.exclude();
+	}
 }

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=453977&r1=453976&r2=453977
==============================================================================
--- 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 Sat Oct  7 11:17:10 2006
@@ -60,6 +60,7 @@
 ICCreateOpClientErr1=Cannot create OperationClient.  ServiceClient is null.
 ICCreateOpClientErr2=Cannot create OperationClient.  Operation qname is null.
 proxyErr1=An attempt was made to invoke method {0}, but this method is not available on the javax.xml.ws.BindingProvider or {1} class.
+proxyErr2=@SOAPBinding annotation Style on SEI and @SOAPBinding annotation Style on Method should be same.
 JAXWSMessageReceiverNoServiceClass=No service class was found for this AxisService.
 EndpointControllerErr2=No Service class is configured for this endpoint.  Processing cannot continue.
 EndpointControllerErr4=Error loading the provider implementation class {0}.  Processing cannot continue.
@@ -91,6 +92,7 @@
 JAXBWrapperErr4=Internal Assertion Error. Number of child objects does not match the number of child names in wrap() method.
 JAXBWrapperErr5=Internal Assertion Error. Number of child names does not match the number of bean properties in JAXB class {0}.
 JAXBWrapperErr6=Internal Assertion Error. JAXB object {0} does not have a bean property named {1}.
+JAXBWrapperErr7=Internal Assertion Error. Method Parameters that holds child objects to create JAXBObject is null.
 JAXBSourceNamespaceErr=The DOMSource must be Namespace Aware.
 AttachmentsNotSupported=SAAJ Attachments are not supported yet.
 protoNotFound00=An associated Protocol was not found for the binding {0}.
@@ -100,4 +102,9 @@
 AsyncListenerErr1=AxisCallback Object cannot be null, Internal error.
 DocLitProxyHandlerErr1=As per WS-I compliance, Multi part WSDL not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter.
 DocLitProxyHandlerErr2 = Method Input parameter for NON Wrapped Request cannot be null.
-SOAP12WithSAAJ12Err=A SOAP 1.2 Message cannot be rendered in an SAAJ 1.2 Object Model.
\ No newline at end of file
+DocLitProxyHandlerErr3=Method parameter type javax.xml.ws.AsyncHandler should only be used with Async Callback operations, method is Async if it returns a Future<?> and endswith letters 'Async'.
+DocLitProxyHandlerErr4=WebParam annotation's Mode cannot be IN for input parameter of type Holder.
+DocLitProxyHandlerErr5=Object Not a Holder type.
+JavaBeanDispatcherErr1=No Java method was found for the operation, if WSDL Operation Name is different from java Method name, make sure you have @WebMethod annotation name present.DocLitProxyHandlerErr2 = Method Input parameter for NON Wrapped Request cannot be null.
+SOAP12WithSAAJ12Err=A SOAP 1.2 Message cannot be rendered in an SAAJ 1.2 Object Model.
+SOAP12WithSAAJ12Err=A SOAP 1.2 Message cannot be rendered in an SAAJ 1.2 Object Model.

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitBareMethodMarshaller.java?view=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitBareMethodMarshaller.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitBareMethodMarshaller.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller;
+
+public interface DocLitBareMethodMarshaller extends MethodMarshaller {
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitWrappedMethodMarshaller.java?view=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitWrappedMethodMarshaller.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/DocLitWrappedMethodMarshaller.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller;
+
+public interface DocLitWrappedMethodMarshaller extends MethodMarshaller {
+
+}

Added: 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=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
+/*
+ * This is a helper class that converts org.apache.axis2.jaxws.message.Message to java Objects
+ * or JAXBObject. It also converts java objects or JAXBObject to org.apache.axis2.jaxws.message.Message.
+ */
+
+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
+	 */
+	public Message marshalRequest(Object[] object) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, MessageException, javax.xml.stream.XMLStreamException;
+	
+	/**
+	 * 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
+	 */
+	public Message marshalResponse(Object returnObject, Object[] holderObjects)throws ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException;
+	
+	/**
+	 * 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);
+	/**
+	 * 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 ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException;
+	
+	/**
+	 * 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. 
+	 * 
+	 * @param message
+	 * @return
+	 */
+	public Object demarshalResponse(Message message, Object[] inputArgs) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, XMLStreamException, MessageException;
+	/**
+	 * This method converts Fault Message to fault java objects. Used on Client Side to extract Fault Object expected by client from message.
+	 * @param message
+	 * @return
+	 */
+	public Object demarshalFaultResponse(Message message);
+	
+	/**
+	 * Indicates if message contains fault.
+	 * @param message
+	 * @return
+	 */
+	public boolean isFault(Message message);
+	
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodParameter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodParameter.java?view=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodParameter.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodParameter.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller;
+
+import javax.jws.WebParam.Mode;
+
+
+/**
+ * Stores Method Parameter as Name and Value. Method Parameter can be an input Method Parameter or output Method parameter.
+ * input Method Parameter is a input to a java Method.
+ * output Method Parameter is a return parameter from a java Method.
+ */
+public class MethodParameter {
+	
+	private String name = null;
+	private Object value = null;
+	private Mode mode = null;
+	private Class type = null;
+	private Class actualType = null; //If parameter is a GenericType, this property stores the actual Type
+	private boolean isHolder = false;
+	
+	public MethodParameter(String name, Object value, Mode mode) {
+		super();
+		this.name = name;
+		this.value = value;
+		this.mode = mode;
+	}
+	public MethodParameter(String name, Object value, Mode mode, Class type, Class actualType, boolean isHolder) {
+		this(name,value,mode);
+		this.type = type;
+		this.isHolder = isHolder;
+		this.actualType = actualType;
+	}
+	public String getName() {
+		return name;
+	}
+	public Object getValue() {
+		return value;
+	}
+	public Mode getMode() {
+		return mode;
+	}
+	public Class getType() {
+		return type;
+	}
+	public void setType(Class type) {
+		this.type = type;
+	}
+	public Class getActualType() {
+		return this.actualType;
+	}
+	public void setActualType(Class actualType) {
+		this.actualType = actualType;
+	}
+	public boolean isHolder() {
+		return isHolder;
+	}
+	public void setHolder(boolean isHolder) {
+		this.isHolder = isHolder;
+	}
+}

Added: 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=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller.factory;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
+import org.apache.axis2.jaxws.marshaller.impl.DocLitBareMethodMarshallerImpl;
+import org.apache.axis2.jaxws.marshaller.impl.DocLitWrappedMethodMarshallerImpl;
+import org.apache.axis2.jaxws.message.Protocol;
+
+
+public class MethodMarshallerFactory {
+
+	public MethodMarshallerFactory() {
+		super();
+		
+	}
+	
+	public MethodMarshaller createDocLitMethodMarshaller(SOAPBinding.ParameterStyle style, ServiceDescription serviceDesc, EndpointDescription endpointDesc, OperationDescription operationDesc, Protocol protocol){
+		if(style == SOAPBinding.ParameterStyle.WRAPPED){
+			return new DocLitWrappedMethodMarshallerImpl(serviceDesc, endpointDesc, operationDesc, protocol);
+		}
+		if(style == SOAPBinding.ParameterStyle.BARE){
+			return new DocLitBareMethodMarshallerImpl(serviceDesc, endpointDesc, operationDesc, protocol);
+		}
+		return null;
+	}
+	
+	public MethodMarshaller createRPCLitMethodMarshaller(SOAPBinding.ParameterStyle style, ServiceDescription serviceDesc, EndpointDescription endpointDesc, OperationDescription operationDesc, Protocol protocol){
+		throw new UnsupportedOperationException("RPC/LIT not supported");
+	}
+}

Added: 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=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller.impl;
+
+import java.util.ArrayList;
+
+import javax.naming.OperationNotSupportedException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.Holder;
+
+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.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;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class DocLitBareMethodMarshallerImpl extends MethodMarshallerImpl
+		implements DocLitBareMethodMarshaller {
+	private static int SIZE = 1;
+	private static Log log = LogFactory.getLog(DocLitBareMethodMarshallerImpl.class);
+	/**
+	 * @param serviceDesc
+	 * @param endpointDesc
+	 * @param operationDesc
+	 */
+	public DocLitBareMethodMarshallerImpl(ServiceDescription serviceDesc,
+			EndpointDescription endpointDesc, OperationDescription operationDesc, Protocol protocol) {
+		super(serviceDesc, endpointDesc, operationDesc, protocol);
+		// TODO Auto-generated constructor stub
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toJAXBObject(org.apache.axis2.jaxws.message.Message)
+	 */
+	@Override
+	public Object demarshalResponse(Message message, Object[] inputArgs) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, XMLStreamException, MessageException{
+		
+		Class returnType = getReturnType();
+		String resultName = operationDesc.getWebResultName();
+		Object bo = null;
+		if(returnType.getName().equals("void")){
+			ArrayList<MethodParameter> mps = toInputMethodParameters(inputArgs);
+			for(MethodParameter mp:mps){
+				if(mp.isHolder()){
+					returnType = mp.getActualType();
+				}
+			}
+			
+		}
+		bo = createBusinessObject(returnType, message);
+		//In a bare case there should not be a situation where there is a return type and a holder.
+		createResponseHolders(bo, inputArgs, true);
+		
+		return bo;
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toObjects(org.apache.axis2.jaxws.message.Message)
+	 */
+	@Override
+	public Object[] demarshalRequest(Message message)throws ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException{
+		
+		ArrayList<Class> inputParams = getInputTypes();
+		//Method has no input parameters
+		if(inputParams.size() == 0){
+			return null;
+		}
+		if(inputParams.size() > SIZE){
+			if (log.isDebugEnabled()) {
+	            log.debug("As per WS-I compliance, Multi part WSDL not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter");
+	        }
+			throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr1"));
+		}
+		
+		Class jaxbClass = inputParams.get(0);
+		
+		Object jaxbObject = createBusinessObject(jaxbClass, message);
+        
+        if (log.isDebugEnabled()) {
+            log.debug("reading input method parameters");
+        }
+        Class rawType = operationDesc.getSEIMethod().getParameterTypes()[0];
+       
+        if(isHolder(rawType)){
+        	
+        	return new Object[]{createHolder(rawType, jaxbObject)};
+        }
+        else{
+        	return new Object[]{jaxbObject};
+        }
+       
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromJAXBObject(java.lang.Object)
+	 */
+	@Override
+	public Message marshalResponse(Object returnObject, Object[] holderObjects) throws ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException{
+		// Response wrapper is basically the return type. so the return object is a jaxbObject. If there is a holder objects then that is the responsewrapper.
+		Class wrapperClazz = getReturnType();
+		String wrapperClazzName = wrapperClazz.getName();
+		String webResult = operationDesc.getWebResultName();
+		
+		//create all holders list
+		ArrayList<Object> objectList = new ArrayList<Object>();
+		if(holderObjects!=null){
+			objectList = toArrayList(holderObjects);
+			for(Object obj:holderObjects){
+				if(!(isHolder(obj))){
+					objectList.remove(obj);
+				}
+			}
+		}
+		if(objectList.size()> SIZE){
+			//More than one holder input parameter found, this is a WS-I violation.
+			if (log.isDebugEnabled()) {
+	            log.debug("As per WS-I compliance, Multi part WSDL not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter");
+	        }
+			throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr1"));
+		}
+		Message message = null;
+		ArrayList<MethodParameter> mps = new ArrayList<MethodParameter>();
+		if(objectList.size() == 0 && wrapperClazz.getName().equals("void")){
+			//No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
+			//doNothing as there is nothing to wrap
+		
+		}
+		if(objectList.size() == 0 && !wrapperClazz.getName().equals("void")){
+			//No holders but a return type example --> public ReturnType someMethod()
+			
+			message = createMessage(returnObject, wrapperClazz, wrapperClazzName);
+		}
+		else{
+			//Holders found and return type or no return type. example --> public ReturnType someMethod(Holder<AHolder>) or public void someMethod(Holder<AHolder>)
+			//Note that SEI implementation will wrap return type in a holder if method has a return type and input param as holder.
+			//WSGen and WsImport Generate Holders with return type as one of the Holder JAXBObject property, if wsdl schema forces a holder and a return type.
+			ArrayList<Class> holderType = getInputTypes();
+			Holder holder = (Holder)objectList.get(0);
+			Object value = holder.value;
+			message = createMessage(value, holderType.get(0), holderType.get(0).getName());
+		}
+		
+		return message;
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromObjects(java.lang.Object[])
+	 */
+	@Override
+	public Message marshalRequest(Object[] objects) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, MessageException, javax.xml.stream.XMLStreamException{
+		
+		
+		ArrayList<MethodParameter> mps = toInputMethodParameters(objects);
+		
+		//WSDL wrapped and running wsImport with non-wrap binding or wsdl un-Wrapped and running wsImport with no binding, EITHER WAYS 
+		//there can be only 0 or 1 Body parts as per WS-I. 
+		if(mps.size()> SIZE){
+			if (log.isDebugEnabled()) {
+	            log.debug("As per WS-I compliance, Multi part WSDL not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter");
+	        }
+			throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr1"));
+		}
+		
+		//Lets handle case where there is one message part or one input parameter
+		Message message = null;
+		if(mps.size() !=0){
+			Object requestObject = null;
+			String requestObjectName = null;
+			Class requestObjectType = null;
+			JAXBContext ctx = null;
+			for(MethodParameter mp : mps){
+				requestObject = mp.getValue();
+				requestObjectName = mp.getName();
+				requestObjectType = mp.getActualType();
+				if(requestObject == null){
+					if (log.isDebugEnabled()) {
+			            log.debug("Method Input parameter for NON Wrapped Request cannot be null");
+			        }
+					throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr2"));
+				}
+			}
+				
+			message = createMessage(requestObject, requestObjectType, requestObjectName);
+		}
+		//no message part case or no input parameter
+		if(mps.size() == 0){
+			message = createEmptyMessage();
+		}
+		
+		return message;
+	}
+
+	@Override
+	public Object demarshalFaultResponse(Message message) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public boolean isFault(Message message) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public Message marshalFaultResponse(Throwable throwable) {
+		throw new UnsupportedOperationException();
+	}
+}

Added: 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=auto&rev=453977
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java Sat Oct  7 11:17:10 2006
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.marshaller.impl;
+
+import java.util.ArrayList;
+
+import javax.naming.OperationNotSupportedException;
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.marshaller.DocLitWrappedMethodMarshaller;
+import org.apache.axis2.jaxws.marshaller.MethodParameter;
+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.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 {
+	private static Log log = LogFactory.getLog(DocLitWrappedMethodMarshallerImpl.class);
+
+	/**
+	 * @param serviceDesc
+	 * @param endpointDesc
+	 * @param operationDesc
+	 */
+	public DocLitWrappedMethodMarshallerImpl(ServiceDescription serviceDesc,
+			EndpointDescription endpointDesc, OperationDescription operationDesc, Protocol protocol) {
+		super(serviceDesc, endpointDesc, operationDesc, protocol);
+		// TODO Auto-generated constructor stub
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toJAXBObject(org.apache.axis2.jaxws.message.Message)
+	 */
+	@Override
+	public Object demarshalResponse(Message message, Object[] inputArgs) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, javax.xml.stream.XMLStreamException, MessageException{
+		Class wrapperClazz = null;
+		String className = operationDesc.getResponseWrapperClassName();
+		//TODO Move this to Operation Description.
+		if(className == null || (className!=null && className.length()==0)){
+			wrapperClazz = getReturnType();
+		}
+		else{		
+			wrapperClazz = loadClass(className);
+		}
+		String resultName = operationDesc.getWebResultName();
+		Object bo = createBusinessObject(wrapperClazz, message);
+		createResponseHolders(bo, inputArgs, false);
+		//if result name is null and that means there is no webResult meaning its a void return.
+		if(resultName !=null){
+		//if ReturnType is not of same type as JAXBBlock business Object then I will look for resultName in Business Object and return that.
+			Object resultObject = findProperty(resultName, bo);
+			return resultObject;
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toObjects(org.apache.axis2.jaxws.message.Message)
+	 */
+	@Override
+	public Object[] demarshalRequest(Message message)throws ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException {
+        String className = operationDesc.getRequestWrapperClassName();
+        Class requestWrapperClazz = loadClass(className);
+        Object jaxbObject = createBusinessObject(requestWrapperClazz, message);
+        
+        if (log.isDebugEnabled()) {
+            log.debug("reading input method parameters");
+        }
+        ArrayList<MethodParameter> mps = toInputMethodParameter(jaxbObject);
+        if (log.isDebugEnabled()) {
+            log.debug("done reading input method parameters");
+        }
+        
+        Object[] contents = new Object[mps.size()];
+        int i =0;
+        for (MethodParameter mp:mps){
+        	contents[i++] =mp.getValue();
+        }
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Object unwrapped");
+        }
+        
+        return contents;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromJAXBObject(java.lang.Object)
+	 */
+	@Override
+	public Message marshalResponse(Object returnObject, Object[] holderObjects)throws ClassNotFoundException, JAXBException, MessageException, JAXBWrapperException, XMLStreamException, InstantiationException, IllegalAccessException {
+		Class wrapperClazz = null;
+		String wrapperClazzName = operationDesc.getResponseWrapperClassName();
+		String webResult = operationDesc.getWebResultName();
+		//TODO Move this to Operation Description.
+		if(wrapperClazzName == null || (wrapperClazzName!=null && wrapperClazzName.length()==0)){
+			wrapperClazz = getReturnType();
+			wrapperClazzName = wrapperClazz.getName();
+			if(log.isDebugEnabled()){
+				log.debug("No ResponseWrapper annotation found, using return type of method as response object");
+			}
+		}
+		else{		
+			wrapperClazz = loadClass(wrapperClazzName);
+		}
+		//create all holders list
+		ArrayList<Object> objectList = new ArrayList<Object>();
+		if(holderObjects!=null){
+			objectList = toArrayList(holderObjects);
+			for(Object obj:holderObjects){
+				if(!(isHolder(obj))){
+					objectList.remove(obj);
+				}
+			}
+		}
+		//No Holders found 
+		ArrayList<MethodParameter> mps = new ArrayList<MethodParameter>();
+		if(objectList.size() == 0 && wrapperClazz.getName().equals("void")){
+			//No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
+			//doNothing as there is nothing to wrap
+		}
+		if(objectList.size() == 0 && !wrapperClazz.getName().equals("void")){
+			//No holders but a return type example --> public ReturnType someMethod()
+			mps = toOutputMethodParameter(returnObject);
+		}
+		else{
+			//Holders found and return type or no return type. example --> public ReturnType someMethod(Holder<String>) or public void someMethod(Holder<String>)
+			mps = toOutputMethodParameter(returnObject, objectList.toArray());
+		}
+		
+        JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+        Object wrapper = wrapperTool.wrap(wrapperClazz, 
+        		wrapperClazzName, mps);
+        
+		Message message = createMessage(wrapper, wrapperClazz, wrapperClazzName);
+		return message;
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromObjects(java.lang.Object[])
+	 */
+	@Override
+	public Message marshalRequest(Object[] objects) throws IllegalAccessException, InstantiationException, ClassNotFoundException, JAXBWrapperException, JAXBException, MessageException, javax.xml.stream.XMLStreamException {
+		
+		String className = operationDesc.getRequestWrapperClassName();
+		Class wrapperClazz = loadClass(className);
+		String localName = operationDesc.getRequestWrapperLocalName();
+		
+		//Get Name Value pair for input parameter Objects, skip AsyncHandler and identify Holders.
+		ArrayList<MethodParameter> methodParameters = toInputMethodParameters(objects);
+		JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
+		if (log.isDebugEnabled()) {
+            log.debug("JAXBWrapperTool attempting to wrap propertes in WrapperClass :" + wrapperClazz);
+        }
+	
+		Object jaxbObject = wrapTool.wrap(wrapperClazz, localName, methodParameters);
+		if (log.isDebugEnabled()) {
+            log.debug("JAXBWrapperTool wrapped following propertes :");
+        }
+		
+		Message message = createMessage(jaxbObject, wrapperClazz, localName);
+		return message;
+	}
+
+	@Override
+	public Object demarshalFaultResponse(Message message) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public boolean isFault(Message message) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public Message marshalFaultResponse(Throwable throwable) {
+		throw new UnsupportedOperationException();
+	}
+	
+}



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


Mime
View raw message