You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2006/07/19 15:44:05 UTC

svn commit: r423462 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: ClientMediator.java client/proxy/ProxyDescriptor.java client/proxy/ProxyHandler.java spi/ServiceDelegate.java

Author: scheu
Date: Wed Jul 19 06:44:05 2006
New Revision: 423462

URL: http://svn.apache.org/viewvc?rev=423462&view=rev
Log:
AXIS2-902
Continued work on the JAX-WS Proxy
Contributor: Nikhil Thaker

Added:
    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/ProxyHandler.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java?rev=423462&r1=423461&r2=423462&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java Wed Jul 19 06:44:05 2006
@@ -19,6 +19,7 @@
 import java.lang.reflect.Proxy;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.axis2.AxisFault;
@@ -31,7 +32,9 @@
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.jaxws.client.JAXBDispatch;
 import org.apache.axis2.jaxws.client.XMLDispatch;
+import org.apache.axis2.jaxws.client.proxy.ProxyHandler;
 import org.apache.axis2.jaxws.handler.PortData;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 /*
  * This class acts as a mediator to creating Proxy or Dispatch implementation when Client makes a call to Service.
@@ -94,27 +97,22 @@
 	}
 
 	// Add required parameter to this method.
-	public <T> T createProxy(JAXWSClientContext<T> clientContext) {
+    public <T> T createProxy(JAXWSClientContext<T> clientContext, ServiceDelegate delegate) {
 		//TODO: Have to rewrite this
+		this.clientContext = clientContext;
 		Class<T> sei = clientContext.getClazz();
 		//read port information from JAXWSClientContext and set that.
 		QName portName = null;
-		if(sei == null){
-    		return null;
-    	}
+		
 		try{
+			
 			AxisController axisController = buildAxisController();
-			axisController.setClientContext(this.clientContext);
-    	
-	    	Proxies proxyHandler = new Proxies(axisController);
-	    	Class[] seiClazz = new Class[]{sei};
-	    	Object proxyClass = Proxy.newProxyInstance(sei.getClassLoader(), seiClazz, proxyHandler);
+			axisController.setClientContext(clientContext);
+	    	ProxyHandler proxyHandler = new ProxyHandler(axisController, delegate);
 	    	
+	    	Class[] seiClazz = new Class[]{sei, BindingProvider.class};
+	    	Object proxyClass = Proxy.newProxyInstance(sei.getClassLoader(), seiClazz, proxyHandler);
 	    	
-	    	/*TODO handle this in AxisController
-	    	*proxyHandler.setAxisService(axisService);
-	    	*proxyHandler.setServiceClient(serviceClient);
-	    	*/
 	    	return sei.cast(proxyClass);
 		}catch(AxisFault e){
     		throw new WebServiceException(e.getMessage());

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java?rev=423462&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyDescriptor.java Wed Jul 19 06:44:05 2006
@@ -0,0 +1,123 @@
+/*
+ * 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.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+/**
+ * ProxyDescriptor is instantiated from ProxyHandler using the Method argument. 
+ * ProxyDescriptor will provide all the annotation details like RequestWrapper class
+ * ResponseWrapper Class, WebParam name etc...
+ *
+ */
+public class ProxyDescriptor {
+	private Method proxyMethod = null;
+	private RequestWrapper requestWrapper= null;
+	private ResponseWrapper responseWrapper= null;
+	private WebParam[] webParam = null;
+	private WebResult webResult = null;
+	
+	public ProxyDescriptor(Method method){
+		this.proxyMethod = method;
+	}
+	
+	//TODO remove this once OperationDescription is implemented
+	public RequestWrapper getRequestWrapper() {
+		if(requestWrapper == null){
+			requestWrapper = proxyMethod.getAnnotation(RequestWrapper.class);
+		}
+		return requestWrapper;
+	}
+	
+	//TODO remove this once OperationDescription is implemented
+	public ResponseWrapper getResponseWrapper() {
+		if(responseWrapper == null){
+			responseWrapper = proxyMethod.getAnnotation(ResponseWrapper.class);
+		}
+		return responseWrapper;
+	}
+	
+	//TODO remove this once OperationDescription is implemented
+	public WebParam[] getWebParam() {
+		if(webParam == null){
+			Annotation[][] paramAnnotation = proxyMethod.getParameterAnnotations();
+			ArrayList<WebParam> webParamList = new ArrayList<WebParam>();
+			for(Annotation[] pa:paramAnnotation){
+				for(Annotation webParam:pa){
+					if(webParam.annotationType()==WebParam.class){
+						webParamList.add((WebParam)webParam);
+					}
+				}
+			}
+			webParam = new WebParam[webParamList.size()];
+			webParamList.toArray(webParam);
+			
+		}
+		return webParam;
+	}
+	
+	//TODO remove this once OperationDescription is implemented
+	public WebResult getWebResult(){
+		if(webResult == null){
+			webResult = proxyMethod.getAnnotation(WebResult.class);
+		}
+		return webResult;
+	}
+	
+	//TODO: refactor this once PropertyDescriptor is implemented.
+	public Class getRequestWrapperClass() throws ClassNotFoundException{
+		return Class.forName(getRequestWrapper().className(), true, ClassLoader.getSystemClassLoader());
+	}
+	
+	public String getRequestWrapperClassName(){
+		return getRequestWrapper().className();
+	}
+	public String getRequestWrapperLocalName(){
+		return getRequestWrapper().localName();
+	}
+	//TODO remove this once OperationDescription is implemented
+	public Class getResponseWrapperClass() throws ClassNotFoundException{
+		return Class.forName(getResponseWrapper().className(), true, ClassLoader.getSystemClassLoader());
+	}
+	public String getResponseWrapperClassName(){
+		return getResponseWrapper().className();
+	}
+	public String getResponseWrapperLocalName(){
+		return getResponseWrapper().localName();
+	}
+	//TODO remove this once OperationDescription is implemented
+	public String getWebResultName(){
+		return getWebResult().name();
+	}
+	
+	public ArrayList<String> getParamNames(){
+		//TODO what if the param itself is a holder class;
+		WebParam[] params = getWebParam();
+		ArrayList<String> names = new ArrayList<String>();
+		for(WebParam webParam:params){
+			names.add(webParam.name());
+		}
+		return names;
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyHandler.java?rev=423462&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyHandler.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyHandler.java Wed Jul 19 06:44:05 2006
@@ -0,0 +1,427 @@
+/*
+ * 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.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.AxisController;
+import org.apache.axis2.jaxws.BindingProvider;
+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.message.Block;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+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.JAXBWrapperTool;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
+
+
+/**
+ * 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 Invoke 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;
+ * TBD
+ * 
+ * RPCLiteral 
+ * TBD
+ * 
+ */
+
+public class ProxyHandler extends BindingProvider implements InvocationHandler {
+
+	//TODO remove axisController once InvocationController code is build.
+	private AxisController axisController = null;
+	//Reference to ServiceDelegate instance that was used to create the Proxy
+	private ServiceDelegate delegate = null;
+	private ProxyDescriptor proxyDescriptor = null;
+	public ProxyHandler(AxisController ac, ServiceDelegate delegate) {
+		super();
+		this.axisController = ac;
+		this.delegate = delegate;
+		setRequestContext();
+	}
+	
+	/* (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(!isValidMethodCall(method)){
+			throw new WebServiceException("Invalid Method-"+method.getName()+ " Method not found in javax.xml.ws.BindingProvider or "+axisController.getClientContext().getClazz() );
+		}
+		
+		if(isBindingProviderInvoked(method)){
+			return method.invoke(this, args);
+		}
+		else{
+			return InvokeSEIMethod(method, args);
+		}
+		
+	}
+	
+	/**
+	 * InvokeSEIMethod reads EndpointInterfaceDescription and finds out if the request is document literal or RPC Literal and check to see if the WSDL is 
+	 * wrapped or unWrapped. It then reads OperationDescription using Method and in case of doc/lit wrapped Request:
+	 * 1) creates request message context for doc/lit wrapped Request.
+	 * 2) creates response message context by calling InvocationController with request message context as input.
+	 * 3) create wrapped response and returns it to the client method call.
+	 * 
+	 * In case of doc/lit unWrapped Request:
+	 * TBD
+	 * 
+	 * In case of RPC/Lit wrapped Request:
+	 * TBD
+	 * 
+	 * In case of RPC/Lit unWrapped Request:
+	 * TBD
+	 * 
+	 * @param method - Method called by Client
+	 * @param args - Argument object to the method call
+	 * @return - returns the returnType of the method call.
+	 * @throws ClassNotFoundException
+	 * @throws JAXBWrapperException
+	 * @throws JAXBException
+	 * @throws MessageException
+	 * @throws XMLStreamException
+	 * @throws IllegalAccessException
+	 * @throws IntrospectionException
+	 * @throws NoSuchFieldException
+	 * @throws InvocationTargetException
+	 * 
+	 * 
+	 */
+	private Object InvokeSEIMethod(Method method, Object[] args)throws ClassNotFoundException, JAXBWrapperException, JAXBException, MessageException, XMLStreamException, IllegalAccessException,IntrospectionException, NoSuchFieldException, InvocationTargetException{
+		
+		/*TODO: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.
+		 */
+		
+		proxyDescriptor = new ProxyDescriptor(method);
+		if(isDocLitWrapped()){
+			MessageContext requestCtx = createDocLitWrappedRequest(method, args);
+			MessageContext responseContext = execute(requestCtx);
+			Object wrappedResponse = createDocLitWrappedResponse(method, responseContext);
+			return wrappedResponse;
+			
+		}
+		return null;
+	}
+	
+	/**
+	 * createDocLitWrappedRequest create request message context. It reads RequestWrapper annotation from OperationDescription and reads the calss name, then reads
+	 * all the webParam annotation on the method and uses JAXBWrapTool to wrap the request as jaxbObject. Create JAXBblock from the jaxbObject and sets OMElement on 
+	 * Request MessageContext, reads Biniding provider properties and set them on request message context and return request message context.
+	 * @param method
+	 * @param objects
+	 * @return
+	 * @throws ClassNotFoundException
+	 * @throws JAXBWrapperException
+	 * @throws JAXBException
+	 * @throws MessageException
+	 * @throws javax.xml.stream.XMLStreamException
+	 */
+	//TODO Refactor this once OperationDescription is implemented.
+	private MessageContext createDocLitWrappedRequest(Method method, Object[] objects)throws ClassNotFoundException, JAXBWrapperException, JAXBException, MessageException, javax.xml.stream.XMLStreamException{
+		/*TODO : getOperationDesc from method name
+		 * and call 
+		 * createDocLitWrapperRequest(od, values);
+		 */
+		Class wrapperClazz = proxyDescriptor.getRequestWrapperClass();
+		ArrayList<String> names = proxyDescriptor.getParamNames();
+		String localName = proxyDescriptor.getResponseWrapperLocalName();
+		Map<String, Object> values = getParamValues(names, objects);
+		JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
+		
+		//TODO:if(@XmlRootElement) annotation found or defined
+		Object jaxbObject = wrapTool.wrap(wrapperClazz, localName,names, values);
+		//TODO: if (!@XmlRootElement) annotation not found or not defined then can I use JAXBElement?
+		//JAXBElement jaxbObject = wrapTool.wrapAsJAXBElement(wrapperClazz, requestWrapper.localName(),names, values);
+		JAXBContext ctx = JAXBContext.newInstance(new Class[]{wrapperClazz});
+		Block reqBlock = createJAXBBlock(jaxbObject, ctx);
+		MessageContext requestCtx = initializeRequest(reqBlock);
+		return requestCtx;
+		
+	}
+	
+	
+	/**
+	 * invokes Axis engine using methods on InvocationController. Create request Invocation context, instantiates AxisInvocationController and runs invoke.
+	 * @param request
+	 * @return
+	 */
+	private MessageContext execute(MessageContext request){
+		//TODO: How do I get binding information.
+		
+		InvocationContext requestIC = InvocationContextFactory.createInvocationContext(null);
+		requestIC.setRequestMessageContext(request);
+		InvocationController controller = new AxisInvocationController();
+		//FIXME: Fix based on how InvocationContext changes to get ServiceClient.
+		requestIC.setServiceClient(axisController.getServiceClient());
+		
+		//TODO: check if the call is OneWay, Async or Sync
+		InvocationContext responseIC = controller.invoke(requestIC);
+		return responseIC.getResponseMessageContext();
+	}
+
+	
+	/**
+	 * CreateDocLitWrappedResponse 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 method
+	 * @param response
+	 * @return
+	 * @throws IllegalAccessException
+	 * @throws ClassNotFoundException
+	 * @throws JAXBWrapperException
+	 * @throws JAXBException
+	 * @throws javax.xml.stream.XMLStreamException
+	 * @throws MessageException
+	 * @throws IntrospectionException
+	 * @throws NoSuchFieldException
+	 * @throws InvocationTargetException
+	 */
+//	TODO Refactor this once OperationDescription is implemented.
+	private Object createDocLitWrappedResponse(Method method, MessageContext response)throws IllegalAccessException, ClassNotFoundException, JAXBWrapperException, JAXBException, javax.xml.stream.XMLStreamException, MessageException, IntrospectionException, NoSuchFieldException, InvocationTargetException{
+		Class wrapperClazz = proxyDescriptor.getResponseWrapperClass();
+		String resultName = proxyDescriptor.getWebResultName();
+		JAXBContext ctx = JAXBContext.newInstance(new Class[]{wrapperClazz});
+		//TODO: I should go away from using messageAsOM and see if I can fetch Block from messageContext!!
+		OMElement om = response.getMessageAsOM();
+		Block resBlock = createJAXBBlock(om, ctx);
+		Object bo = resBlock.getBusinessObject(true);
+		return getWebResultObject(wrapperClazz, bo, resultName);
+	}
+	
+	private Block createJAXBBlock(Object jaxbObject, JAXBContext context) throws MessageException{
+		JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+		return factory.createFrom(jaxbObject,context,null);
+		
+	}
+	
+	private Block createJAXBBlock(OMElement om, JAXBContext context)throws javax.xml.stream.XMLStreamException{
+		JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
+		return factory.createFrom(om,context,null);
+		
+	}
+
+	//TODO: should I unwrap the bo or use property descriptor?
+	private PropertyDescriptor gerPropertyDescriptor(Class returnClazz, String propertyName)throws IntrospectionException, NoSuchFieldException{
+		PropertyDescriptor[] allPds = Introspector.getBeanInfo(returnClazz).getPropertyDescriptors();
+		Field[] fields = returnClazz.getDeclaredFields();
+		for(PropertyDescriptor pd:allPds){
+			for(Field field:fields){
+				String javaFieldName = field.getName();
+				String pdName = pd.getDisplayName();
+				if(javaFieldName.equals(pdName)){
+					if(javaFieldName.equals(propertyName)){
+						return pd;
+						
+					}else{
+						XmlElement xmlElement =field.getAnnotation(XmlElement.class);
+						if(xmlElement == null){
+							//TODO:What happens if xmlElement not defined.
+							
+						}
+						String xmlName =xmlElement.name();
+						if(xmlName.equals(propertyName)){
+							return pd;
+						}
+						if(xmlName.toLowerCase().equals(propertyName.toLowerCase())){
+							return pd;
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+	//TODO: refactor this once PropertyDescriptor is implemented.
+	private Map<String, Object> getParamValues(ArrayList<String> names, Object[] objects){
+		Map<String, Object> values = new Hashtable<String, Object>();
+		int i=0;
+		for(Object obj:objects){
+			values.put(names.get(i++), obj);
+		}
+		return values;
+	}
+	//TODO remove this once OperationDescription is implemented
+	
+	/** 
+	 * reads PropertyDescritpr and invokes  get method on result property and returns the object.
+	 * @param wrapperClazz
+	 * @param businessObject
+	 * @param propertyName
+	 * @return
+	 * @throws NoSuchFieldException
+	 * @throws IntrospectionException
+	 * @throws InvocationTargetException
+	 * @throws IllegalAccessException
+	 */
+	private Object getWebResultObject(Class wrapperClazz, Object businessObject, String propertyName) throws NoSuchFieldException, IntrospectionException,InvocationTargetException, IllegalAccessException{
+		PropertyDescriptor pd = gerPropertyDescriptor(wrapperClazz, propertyName);
+		if(pd == null){
+			//TODO: what happens if pd not found.
+		}
+		Method readMethod = pd.getReadMethod();
+		Object webResult = readMethod.invoke(wrapperClazz.cast(businessObject), null);
+		return webResult;
+	}
+	
+	private MessageContext initializeRequest(Block messageBlock) throws XMLStreamException, MessageException{
+		MessageContext request = new MessageContext();
+		request.setMessageAsOM(messageBlock.getOMElement());
+		request.getProperties().putAll(getRequestContext());
+	
+		return request;
+		
+	}
+
+	private boolean isBindingProviderInvoked(Method method){
+		Class SEIClass = axisController.getClientContext().getClazz();
+		Class methodsClass = method.getDeclaringClass();
+		return (SEIClass == methodsClass)?false:true;
+	}
+	
+	private boolean isDocLitRaw(){
+		/* TODO: if(EndPoinInterfaceDescriptor.clientCall == Doc/literal) && OperationDescriptor.isWrapped() == false){ 
+		 * return true; 
+		 * else
+		 * return false;
+		 */
+		return false;
+	}
+	
+	private boolean isDocLitWrapped(){
+		/* TODO: if(EndPoinInterfaceDescriptor.clientCall == Doc/literal) && OperationDescriptor.isWrapped() == true){ 
+		 * return true; 
+		 * else
+		 * return false;
+		 */
+		return true;
+	}
+	
+	private boolean isRPCLitRaw(){
+		/* TODO: if(EndPoinInterfaceDescriptor.clientCall == RPC/literal) && OperationDescriptor.isWrapped() == false){ 
+		 * return true; 
+		 * else
+		 * return false;
+		 */
+		return false;
+	}
+	
+	private boolean isRPCLitWrapped(){
+		/* TODO: if(EndPoinInterfaceDescriptor.clientCall == RPC/literal) && OperationDescriptor.isWrapped() == true){ 
+		 * return true; 
+		 * else
+		 * return false;
+		 */
+		return false;
+	}
+	private boolean isValidMethodCall(Method method){
+		//TODO: remove reference to axisController
+		Class SEIClass = axisController.getClientContext().getClazz();
+		Class clazz = method.getDeclaringClass();
+		if(clazz == javax.xml.ws.BindingProvider.class || clazz == SEIClass){
+			return true;
+		}
+		return false;
+	}
+	//TODO: remove reference to AxisController.
+	protected void setAxisController(AxisController ac) {
+		this.axisController = ac;
+	}
+	
+	public void setDelegate(ServiceDelegate delegate) {
+		this.delegate = delegate;
+	}
+	
+	protected void setRequestContext() {
+		String endPointAddress = axisController.getEndpointAddress();
+		WSDLWrapper wsdl = delegate.getServiceDescription().getWSDLWrapper();
+		QName serviceName = delegate.getServiceName();
+		QName portName = axisController.getPortName();
+		if (endPointAddress != null && !"".equals(endPointAddress)) {
+			getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+					endPointAddress);
+		} else if (wsdl != null) {
+			String soapAddress = wsdl.getSOAPAddress(serviceName, portName);
+			getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+					soapAddress);
+		}
+
+		if (wsdl != null) {
+			String soapAction = wsdl.getSOAPAction(serviceName, portName);
+			getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
+					soapAction);
+		}
+	}
+	
+	
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?rev=423462&r1=423461&r2=423462&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Wed Jul 19 06:44:05 2006
@@ -178,47 +178,40 @@
     }
 
     @Override
-    public <T> T getPort(Class<T> sei) {
-        // TODO Auto-generated method stub
-    	if(sei == null){
-    		return null;
-    	}
-    	JAXWSClientContext<T> clientContext = new JAXWSClientContext<T>();
-    	//Set all the required properties for JAXWSClientContext.
-    	
-    	return mediator.createProxy(clientContext);
-    	
-    	
-    	/* TODO move this code to ClientMediators CreateProxy() 
-    	Class[] seiClazz = new Class[]{sei};
-    	Object proxyClass = Proxy.newProxyInstance(sei.getClassLoader(), seiClazz, proxyHandler);
-    	createAxisService();
-    	proxyHandler.setAxisService(axisService);
-    	proxyHandler.setServiceClient(serviceClient);
-    	*/
+    public <T> T getPort(Class<T> sei) throws WebServiceException {
+       return getPort(null, sei);
     }
      
     @Override
-    public <T> T getPort(QName qname, Class<T> sei) {
-        // TODO Auto-generated method stub
+    public <T> T getPort(QName qname, Class<T> sei) throws WebServiceException {
+    	/* TODO Check to see if WSDL Location is provided.
+         * if not check WebService annotation's WSDLLocation
+         * if both are not provided then throw exception.
+         */
+        
+    	if(!isValidWSDLLocation()){
+    		//TODO: Should I throw Exception if no WSDL
+    		//throw new WebServiceException("WSLD Not found");
+    	}
     	if(sei == null){
-    		return null;
+    		throw new WebServiceException("Invalid Service Endpoint Interface Class");
+    	}
+    	/*TODO: if portQname is null then fetch it from annotation. 
+    	 * if portQname is provided then add that to the ports table.
+    	 */
+    	if(qname!=null){
+    		String address = "";
+    		if(isValidWSDLLocation()){
+    			address = getWSDLWrapper().getSOAPAddress(serviceQname, qname);
+    		}
+    		if(ports.get(qname)==null){
+    			addPort(qname, null, address);
+    		}
     	}
-    	
-    	JAXWSClientContext<T> clientContext = new JAXWSClientContext<T>();
+   	
+    	JAXWSClientContext<T> clientContext = createClientContext(ports.get(qname), sei, null);
     	//Set all the required properties for JAXWSClientContext.
-    	
-    	return mediator.createProxy(clientContext);
-    	/*TODO move this code to ClientMediators CreateProxy() 
-    	this.portQname = qname;
-    	Proxies proxyHandler = new Proxies();
-    	Class[] seiClazz = new Class[]{sei};
-    	Object proxyClass = Proxy.newProxyInstance(sei.getClassLoader(), seiClazz, proxyHandler);
-    	createAxisService();
-    	proxyHandler.setAxisService(axisService);
-    	proxyHandler.setServiceClient(serviceClient);
-    	return sei.cast(proxyClass);
-    	*/
+    	return mediator.createProxy(clientContext, this);
       
     }
     



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