You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by an...@apache.org on 2003/03/05 17:56:16 UTC

cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers ProviderUtils.java

antelder    2003/03/05 08:56:16

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFOperation_ApacheAxis.java
               java/src/org/apache/wsif WSIFConstants.java
               java/src/org/apache/wsif/base WSIFServiceImpl.java
               java/src/org/apache/wsif/util WSIFUtils.java
               java/src/org/apache/wsif/providers ProviderUtils.java
  Log:
  - save auto determined types in the context to save having to do multiple schema parsing, and change code to use this
  - AXIS provider allow setting user HTTP headers from the context
  - move all the unwrapping code from wsifutils to providerutils
  
  Revision  Changes    Path
  1.73      +25 -3     xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- WSIFOperation_ApacheAxis.java	4 Mar 2003 17:16:13 -0000	1.72
  +++ WSIFOperation_ApacheAxis.java	5 Mar 2003 16:56:15 -0000	1.73
  @@ -59,8 +59,8 @@
   
   import java.rmi.RemoteException;
   import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.HashMap;
  +import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  @@ -115,6 +115,7 @@
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPFaultElement;
   import org.apache.axis.message.SOAPHeaderElement;
  +import org.apache.axis.transport.http.HTTPConstants;
   import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFCorrelationId;
   import org.apache.wsif.WSIFException;
  @@ -874,7 +875,7 @@
   				QName elementName = p.getElementName();
   				if (elementName != null && operationName.equals(elementName.getLocalPart())) {
   				   this.inputUnwrappedSOAPParts = 
  -				      ProviderUtils.unWrapPart(p, getDefinition());
  +				      ProviderUtils.unWrapPart(p, getDefinition(), context);
   				}
   			}
   			if (outputSOAPParts.size() == 1) {
  @@ -883,7 +884,7 @@
   				QName elementName = p.getElementName();
   				if (elementName != null && s.equals(elementName.getLocalPart())) {
   				   this.outputUnwrappedSOAPParts = 
  -				      ProviderUtils.unWrapPart(p, getDefinition());
  +				      ProviderUtils.unWrapPart(p, getDefinition(), context);
   				}
   			}
   		}
  @@ -1820,6 +1821,8 @@
   		
           Object[] axisInputs = soapBodies.toArray(); 
   
  +//TODO:        call.setEncodingStyle("");
  +
   		Trc.event(this, "Invoking AXIS call", call, axisInputs);
   		Object axisResponse; // the response should be a Vector of RPCElement objects
   		try {
  @@ -2606,6 +2609,25 @@
   		} catch (WSIFException ex) {
   			Trc.ignoredException(ex);
   		}
  +
  +        o = null;
  +		try {
  +			name = WSIFConstants.CONTEXT_REQUEST_HTTP_HEADERS;
  +			o = context.getObjectPart(name);
  +		} catch (WSIFException ex) {
  +			Trc.ignoredException(ex);
  +		}
  +    	if (o instanceof Hashtable) {
  +        	call.setProperty(
  +    	        HTTPConstants.REQUEST_HEADERS,
  +    		    (Hashtable) o);
  +		} else {
  +			throw new WSIFException(
  +			    "value type must be java.util.Hashtable for context part '"
  +                + WSIFConstants.CONTEXT_REQUEST_HTTP_HEADERS
  +                + "'"); 			    
  +    	}
  +    	
   	}
   
       /**
  
  
  
  1.20      +18 -0     xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java
  
  Index: WSIFConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- WSIFConstants.java	27 Feb 2003 15:46:30 -0000	1.19
  +++ WSIFConstants.java	5 Mar 2003 16:56:15 -0000	1.20
  @@ -132,6 +132,18 @@
           "org.apache.wsif.soap.RequestHeaders";
   
       /**
  +     *  WSIF context part name for HTTP headers  
  +     */
  +    public static final String CONTEXT_REQUEST_HTTP_HEADERS =
  +        "org.apache.wsif.http.RequestHeaders";
  +
  +    /**
  +     *  WSIF context part name for HTTP headers  
  +     */
  +    public static final String CONTEXT_RESPONSE_HTTP_HEADERS =
  +        "org.apache.wsif.http.ResponseHeaders";
  +
  +    /**
        *  WSIF context part name for SOAP headers  
        */
       public static final String CONTEXT_REQUEST_SOAP_HEADERS =
  @@ -178,6 +190,12 @@
       public static final String CONTEXT_OPERATION_STYLE_MESSAGE =
           "message";
   
  +    /**
  +     *  WSIF context part name for the schema types iterator 
  +     */
  +    public static final String CONTEXT_SCHEMA_TYPES =
  +        "org.apache.wsif.schematypes";
  +        
       /**
        *  SOAP faults WSIFMessage part name for the fault code
        */
  
  
  
  1.33      +10 -0     xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java
  
  Index: WSIFServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WSIFServiceImpl.java	26 Feb 2003 15:55:18 -0000	1.32
  +++ WSIFServiceImpl.java	5 Mar 2003 16:56:16 -0000	1.33
  @@ -59,6 +59,7 @@
   
   import java.io.IOException;
   import java.util.ArrayList;
  +import java.util.Collections;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
  @@ -80,6 +81,7 @@
   import javax.wsdl.xml.WSDLLocator;
   import javax.xml.namespace.QName;
   
  +import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFMessage;
   import org.apache.wsif.WSIFPort;
  @@ -1011,6 +1013,14 @@
               		Trc.ignoredException(ioe);
               	}
               }
  +            
  +            // Add the list of types to the context message so that providers can 
  +            // use the information if needed
  +            WSIFMessage ctx = getContext();
  +            ctx.setObjectPart(
  +                WSIFConstants.CONTEXT_SCHEMA_TYPES,
  +                Collections.unmodifiableList(schemaTypes));
  +            setContext(ctx);
               
               schemaTypesInitialised = true;
           }
  
  
  
  1.33      +4 -53     xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java
  
  Index: WSIFUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WSIFUtils.java	4 Mar 2003 16:41:40 -0000	1.32
  +++ WSIFUtils.java	5 Mar 2003 16:56:16 -0000	1.33
  @@ -1368,66 +1368,17 @@
       }
       
   	/**
  -	 * Tests if this is wrapped document literal stype operation.
  -	 * An operation is wrapped if:
  -	 *    - there is only one input or output message part
  -	 *      and that part is an element not a type 
  -	 *      (MIME means there can be many parts, so all this 
  -	 *       can check is that there is only one element part)
  -	 *    - the message name is the same as the operation name
  -	 *      (for a response the operation name is appened with "Response")
  +	 * @deprecated use org.apache.wsif.providers.ProviderUtils.isWrappedDocLiteral
   	 */
   	public static boolean isWrappedDocLiteral(List parts, String operationName) {
  -		boolean wrapped = !(parts==null);
  -		Part elementPart = null;
  -		for (int i = 0; wrapped && i < parts.size(); i++) {
  -			Part p = (Part) parts.get(i);
  -			if (p.getElementName() != null) {
  -				if (elementPart == null) {
  -					elementPart = p;
  -   				    String pName = p.getElementName().getLocalPart();
  -				    if (!operationName.equals(pName)) {
  -					   wrapped = false;
  -				    }
  -				} else {
  -					wrapped = false;
  -				}
  -			}
  -		}
  -		return wrapped;
  +		return ProviderUtils.isWrappedDocLiteral(parts, operationName);
   	}
   
   	/**
  -	 * Gets the wrapped Part if this is wrapped document literal
  -	 * stype operation. An operation is wrapped if:
  -	 *    - there is only one input or output message part
  -	 *      and that part is an element not a type 
  -	 *      (MIME means there can be many parts, so all this 
  -	 *       can check is that there is only one element part)
  -	 *    - the message name is the same as the operation name
  -	 *      (for a response the operation name is appened with "Response")
  +	 * @deprecated use org.apache.wsif.providers.ProviderUtils.getWrappedDocLiteralPart
   	 */
   	public static Part getWrappedDocLiteralPart(List parts, String operationName) {
  -		boolean wrapped = !(parts==null);
  -		Part elementPart = null;
  -		for (int i = 0; wrapped && i < parts.size(); i++) {
  -			Part p = (Part) parts.get(i);
  -			if (p.getElementName() != null) {
  -				if (elementPart == null) {
  -					elementPart = p;
  -   				    String pName = p.getElementName().getLocalPart();
  -				    if (!operationName.equals(pName)) {
  -					   wrapped = false;
  -				    }
  -				} else {
  -					wrapped = false;
  -				}
  -			}
  -		}
  -		if (!wrapped) {
  -			elementPart = null;
  -		}
  -		return elementPart;
  +        return ProviderUtils.getWrappedDocLiteralPart(parts, operationName);
   	}
   
   	/**
  
  
  
  1.5       +85 -2     xml-axis-wsif/java/src/org/apache/wsif/providers/ProviderUtils.java
  
  Index: ProviderUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ProviderUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProviderUtils.java	27 Feb 2003 15:46:30 -0000	1.4
  +++ ProviderUtils.java	5 Mar 2003 16:56:16 -0000	1.5
  @@ -65,7 +65,10 @@
   import javax.wsdl.Part;
   import javax.xml.namespace.QName;
   
  +import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFException;
  +import org.apache.wsif.WSIFMessage;
  +import org.apache.wsif.logging.Trc;
   import org.apache.wsif.schema.ComplexType;
   import org.apache.wsif.schema.ElementType;
   import org.apache.wsif.schema.Parser;
  @@ -315,12 +318,92 @@
   	}   	
   
   	/**
  +	 * Tests if this is wrapped document literal stype operation.
  +	 * An operation is wrapped if:
  +	 *    - there is only one input or output message part
  +	 *      and that part is an element not a type 
  +	 *      (MIME means there can be many parts, so all this 
  +	 *       can check is that there is only one element part)
  +	 *    - the message name is the same as the operation name
  +	 *      (for a response the operation name is appened with "Response")
  +	 */
  +	public static boolean isWrappedDocLiteral(List parts, String operationName) {
  +		boolean wrapped = !(parts==null);
  +		Part elementPart = null;
  +		for (int i = 0; wrapped && i < parts.size(); i++) {
  +			Part p = (Part) parts.get(i);
  +			if (p.getElementName() != null) {
  +				if (elementPart == null) {
  +					elementPart = p;
  +   				    String pName = p.getElementName().getLocalPart();
  +				    if (!operationName.equals(pName)) {
  +					   wrapped = false;
  +				    }
  +				} else {
  +					wrapped = false;
  +				}
  +			}
  +		}
  +		return wrapped;
  +	}
  +
  +	/**
  +	 * Gets the wrapped Part if this is wrapped document literal
  +	 * stype operation. An operation is wrapped if:
  +	 *    - there is only one input or output message part
  +	 *      and that part is an element not a type 
  +	 *      (MIME means there can be many parts, so all this 
  +	 *       can check is that there is only one element part)
  +	 *    - the message name is the same as the operation name
  +	 *      (for a response the operation name is appened with "Response")
  +	 */
  +	public static Part getWrappedDocLiteralPart(List parts, String operationName) {
  +		boolean wrapped = !(parts==null);
  +		Part elementPart = null;
  +		for (int i = 0; wrapped && i < parts.size(); i++) {
  +			Part p = (Part) parts.get(i);
  +			if (p.getElementName() != null) {
  +				if (elementPart == null) {
  +					elementPart = p;
  +   				    String pName = p.getElementName().getLocalPart();
  +				    if (!operationName.equals(pName)) {
  +					   wrapped = false;
  +				    }
  +				} else {
  +					wrapped = false;
  +				}
  +			}
  +		}
  +		if (!wrapped) {
  +			elementPart = null;
  +		}
  +		return elementPart;
  +	}
  +
  +    /**
   	 * Unwraps a wrapped DocLit style part.
   	 */
   	public static List unWrapPart(Part p, Definition def) throws WSIFException {
  +		return unWrapPart(p, def, null);
  +	}
  +	
  +	/**
  +	 * Unwraps a wrapped DocLit style part.
  +	 */
  +	public static List unWrapPart(Part p, Definition def, WSIFMessage context) throws WSIFException {
   
  -		ArrayList l = new ArrayList();
  -		Parser.getAllSchemaTypes(def, l, null);
  +		ArrayList l = null;
  +        if (context != null) {
  +            try {
  +                l = (ArrayList) context.getObjectPart(WSIFConstants.CONTEXT_SCHEMA_TYPES);
  +            } catch (Exception e) {
  +                Trc.ignoredException(e);
  +            }
  +        }
  +        if (l == null) {
  +        	l = new ArrayList();
  +			Parser.getAllSchemaTypes(def, l, null);
  +        }
   		if (l == null || l.size()<1) {
   			throw new WSIFException("no schema elements found");
   		}