ws-wsif-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers ProviderUtils.java
Date Thu, 27 Feb 2003 15:46:31 GMT
antelder    2003/02/27 07:46:31

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFPort_ApacheAxis.java
                        WSIFOperation_ApacheAxis.java
               java/src/org/apache/wsif/base WSIFClientProxy.java
               java/src/org/apache/wsif WSIFConstants.java
               java/src/org/apache/wsif/util WSIFUtils.java
               java/src/org/apache/wsif/providers ProviderUtils.java
  Log:
  Tidy up and doc style helpers:
  - move doc style utility methods from WSIFUtils to ProviderUtils and change classes to use
ProviderUtils
  - allow overrideing operation style wrapped/document/message from the context message
  - change doc style operations to use the portType namespace for the operation name namespace
  - change AXIS provider to use setProperty not setScopedProperty (for AXIS 1.1 compat)
  - correct type of unwrapped part when its not an element
  
  Revision  Changes    Path
  1.24      +12 -0     xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java
  
  Index: WSIFPort_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- WSIFPort_ApacheAxis.java	17 Jan 2003 16:29:07 -0000	1.23
  +++ WSIFPort_ApacheAxis.java	27 Feb 2003 15:46:30 -0000	1.24
  @@ -338,6 +338,18 @@
   	}
   
   	/**
  +	 * Returns the namespace of the WSDL portType used by this Binding.
  +	 * @return String   the portType namespace
  +	 */
  +	public String getPortTypeNamespace() {
  +		Trc.entry(this);
  +		String portTypeNamespace =  
  +    		port.getBinding().getPortType().getQName().getNamespaceURI();
  +   		Trc.exit(portTypeNamespace);
  +		return portTypeNamespace;
  +	}
  +
  +	/**
   	 * Gets the AXIS Call object being used by this WSIFPort 
   	 * @return Call   the AXIS Call object
   	 * @throws WSIFException  if there is an exception creating the AXIS Call
  
  
  
  1.70      +53 -54    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.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- WSIFOperation_ApacheAxis.java	22 Jan 2003 16:39:08 -0000	1.69
  +++ WSIFOperation_ApacheAxis.java	27 Feb 2003 15:46:30 -0000	1.70
  @@ -123,6 +123,7 @@
   import org.apache.wsif.WSIFResponseHandler;
   import org.apache.wsif.base.WSIFDefaultOperation;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.providers.WSIFDynamicTypeMapping;
   import org.apache.wsif.util.TypeSerializerInfo;
  @@ -843,7 +844,7 @@
   				QName elementName = p.getElementName();
   				if (elementName != null && operationName.equals(elementName.getLocalPart()))
{
   				   this.inputUnwrappedSOAPParts = 
  -				      WSIFUtils.unWrapPart(p, getDefinition());
  +				      ProviderUtils.unWrapPart(p, getDefinition());
   				}
   			}
   			if (outputSOAPParts.size() == 1) {
  @@ -852,7 +853,7 @@
   				QName elementName = p.getElementName();
   				if (elementName != null && s.equals(elementName.getLocalPart())) {
   				   this.outputUnwrappedSOAPParts = 
  -				      WSIFUtils.unWrapPart(p, getDefinition());
  +				      ProviderUtils.unWrapPart(p, getDefinition());
   				}
   			}
   		}
  @@ -1371,7 +1372,7 @@
   		return type;
       }
   
  -	public boolean invokeRequestResponseOperation(
  +	protected boolean invokeRequestResponseOperation(
   		WSIFMessage inMsg,
   		WSIFMessage outMsg,
   		WSIFMessage faultMsg)
  @@ -1392,15 +1393,7 @@
   		}
   		call.setSOAPActionURI(getSoapActionURI());
   
  -  		if (WSIFAXISConstants.STYLE_DOCUMENT.equals(operationStyle)
  -        && isInputMessageUnWrapped(inMsg)) {
  -		    operationStyle = WSIFAXISConstants.AXIS_STYLE_WRAPPED;
  -        }
  -
  -        // TODO: what about wrapped messaging? Not supported yet
  -    	if (isMessaging(inMsg)) {
  -	    	operationStyle = WSIFAXISConstants.AXIS_STYLE_MESSAGE;
  -    	}
  +        operationStyle = getOperationStyle(inMsg);
   
   		Transport axistransport = getTransport();
   		WSIFJMSDestination dest = null;
  @@ -1441,6 +1434,29 @@
   		return workedOK;
   	}
   
  +    protected String getOperationStyle(WSIFMessage msg) {
  +    	String style = operationStyle;
  +    	
  +        try {
  +        	WSIFMessage context = getContext();
  +    	    style = (String) context.getObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE);
  +        } catch (WSIFException e) {
  +            Trc.ignoredException(e);
  +
  +      		if (WSIFAXISConstants.STYLE_DOCUMENT.equals(operationStyle)
  +            && isInputMessageUnWrapped(msg)) {
  +		        style = WSIFAXISConstants.AXIS_STYLE_WRAPPED;
  +            }
  +
  +            // TODO: what about wrapped messaging? Not supported yet
  +        	if (isMessaging(msg)) {
  +	        	style = WSIFAXISConstants.AXIS_STYLE_MESSAGE;
  +    	    }
  +        }
  +    		
  +    	return style;
  +    }
  +
       /**
        * This attempts to determine if the WSIF input message parts are 
        * for a wrapped or unwrapped style operation. Tricky to tell for
  @@ -1599,49 +1615,29 @@
            * not include the attachments, so take the part ordering from 
            * the ordering of the parts in the original message.
            */
  -        if (inputMIMEParts.isEmpty())
  -        {
  -            // setup the input SOAP parts
  -            for (int i = 0; i < soapParts.size(); i++)
  -            {
  -                Part p = (Part) soapParts.get(i);
  -                String partName = p.getName();
  -                if (!inJmsProps.containsKey(partName))
  -                {
  -                    if (WSIFAXISConstants
  -                        .STYLE_DOCUMENT
  -                        .equals(operationStyle))
  -                    {
  -                        QName qn = p.getElementName();
  -                        if (qn != null)
  -                        {
  -                            partName = qn.getLocalPart();
  -                        }
  -                    }
  -                    QName name = new QName(inputNamespace, partName);
  -                    QName type = getPartType(p);
  -                    call.addParameter(name, type, ParameterMode.IN);
  +        List parts;
  +        if (inputMIMEParts.isEmpty()) {
  +        	parts = soapParts;
  +        } else {
  +         	parts = portTypeOperation.getInput().getMessage().getOrderedParts(null);
  +        }
  +        for (Iterator i = parts.iterator(); i.hasNext(); ) {
  +            Part p = (Part) i.next();
  +            String partName = p.getName();
  +            if (WSIFAXISConstants.STYLE_DOCUMENT.equals(operationStyle)) {
  +                QName qn = p.getElementName();
  +                if (qn != null) {
  +                    partName = qn.getLocalPart();
                   }
               }
  -        }
  -        else
  -        {
  -            // This order should include both the attachments and 
  -            // the non-attachments.
  -            List order =
  -                portTypeOperation.getInput().getMessage().getOrderedParts(null);
  -            Iterator it = order.iterator();
  -            while (it.hasNext())
  -            {
  -                Part p = (Part) it.next();
  -
  -                // Only add the part if it hasn't been excluded by the 
  -                // soap:body parts="?"
  -                if (inputMIMEParts.contains(p) || soapParts.contains(p))
  -                {
  -                    QName name = new QName(inputNamespace, p.getName());
  +            if (!inJmsProps.containsKey(partName)) {
  +                if (inputMIMEParts.isEmpty()
  +                || (inputMIMEParts.contains(p) || soapParts.contains(p))) {
  +                    QName name = new QName(inputNamespace, partName);
                       QName type = getPartType(p);
                       call.addParameter(name, type, ParameterMode.IN);
  +//                    call.addParameter(partName, type, ParameterMode.IN);
  +//TODO: sort out param namespace
                   }
               }
           }
  @@ -1702,10 +1698,13 @@
   
   		// setup the call object
   		call.setOperationName(
  -			new QName(getInputNamespace(), portTypeOperation.getName()));
  -		call.setScopedProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
  -		call.setScopedProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
  +			new QName(wsifPort.getPortTypeNamespace(), portTypeOperation.getName()));
  +
  +		call.setProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
  +		call.setProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
  +
   		call.setOperationStyle(operationStyle);
  +//TODO???        call.setOperationUse("literal");
           setCallParameterNames(call);
   
   		Object[] inputValues = getInputMessageValues(inMsg, null);
  
  
  
  1.19      +2 -1      xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java
  
  Index: WSIFClientProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- WSIFClientProxy.java	26 Feb 2003 17:27:30 -0000	1.18
  +++ WSIFClientProxy.java	27 Feb 2003 15:46:30 -0000	1.19
  @@ -83,6 +83,7 @@
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.compiler.util.TypeMapping;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.providers.WSIFDynamicTypeMapping;
   import org.apache.wsif.util.WSIFUtils;
  @@ -647,7 +648,7 @@
   		throws WSIFException {
   	    Part p = WSIFUtils.getWrappedDocLiteralPart(parts, operationName);
   		if (p != null) {
  -		    List unWrappedParts = WSIFUtils.unWrapPart(p, def);
  +		    List unWrappedParts = ProviderUtils.unWrapPart(p, def);
   			parts.remove(p);
   			parts.addAll(unWrappedParts);
   		}
  
  
  
  1.19      +12 -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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- WSIFConstants.java	26 Feb 2003 15:55:22 -0000	1.18
  +++ WSIFConstants.java	27 Feb 2003 15:46:30 -0000	1.19
  @@ -155,6 +155,12 @@
           "org.apache.wsif.axis.operationStyle";
   
       /**
  +     *  WSIF context value for AXIS document operation style  
  +     */
  +    public static final String CONTEXT_OPERATION_STYLE_DOCUMENT =
  +        "document";
  +
  +    /**
        *  WSIF context value for AXIS wrapped operation style  
        */
       public static final String CONTEXT_OPERATION_STYLE_WRAPPED =
  @@ -165,6 +171,12 @@
        */
       public static final String CONTEXT_OPERATION_STYLE_UNWRAPPED =
           "unwrapped";
  +
  +    /**
  +     *  WSIF context value for AXIS message operation style  
  +     */
  +    public static final String CONTEXT_OPERATION_STYLE_MESSAGE =
  +        "message";
   
       /**
        *  SOAP faults WSIFMessage part name for the fault code
  
  
  
  1.30      +4 -52     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WSIFUtils.java	26 Feb 2003 15:55:24 -0000	1.29
  +++ WSIFUtils.java	27 Feb 2003 15:46:30 -0000	1.30
  @@ -100,6 +100,7 @@
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
   import org.apache.wsif.mapping.WSIFDefaultMapper;
  +import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.schema.ComplexType;
   import org.apache.wsif.schema.ElementType;
   import org.apache.wsif.schema.Parser;
  @@ -1343,61 +1344,12 @@
   	}
   
   	/**
  -	 * Unwraps a wrapped DocLit style part.
  +	 * @deprecated use org.apache.wsif.providers.ProviderUtils.unWrapPart
   	 */
   	public static List unWrapPart(Part p, Definition def) throws WSIFException {
  -
  -		ArrayList l = new ArrayList();
  -		Parser.getAllSchemaTypes(def, l, null);
  -		if (l == null || l.size()<1) {
  -			throw new WSIFException("no schema elements found");
  -		}
  -
  -	    QName partQN = p.getElementName();
  -		if (partQN == null) {
  -			throw new WSIFException("part has no QName");
  -		}
  -	    
  -		ElementType et = null;
  -		for (int i=0; i<l.size() && et==null; i++ ){
  -			Object o = l.get(i);
  -			if ( o instanceof ElementType ) {
  -                QName etQN = ((ElementType)o).getTypeName();
  -				if ( partQN.equals(etQN) ){
  -					et = (ElementType)o;
  -				}
  -			}
  -		}
  -		if (et == null) {
  -			throw new WSIFException("no ElementType found for part: " + p);
  -		}
  -
  -		List children = et.getChildren();
  -		if (children == null || l.size()<1) {
  -			throw new WSIFException("no ComplexType children on elementType: " + et);
  -		}
  -		
  -		ComplexType ct = (ComplexType) children.get(0);
  -		SequenceElement[] se = ct.getSequenceElements();
  -		if (se == null) {
  -			throw new WSIFException("no sequence elements found on: " + ct);
  -		}
  -		
  -		ArrayList unWrappedParts = new ArrayList();
  -		for (int i=0; i< se.length; i++) {
  -		   PartImpl np = new PartImpl();
  -		   QName type = se[i].getTypeName();
  -		   if (type==null) {
  -			  throw new WSIFException("sequence element has no type name: " + se[i]);
  -		   }
  -		   np.setName(type.getLocalPart());
  -		   np.setElementName(se[i].getElementType());
  -   		   unWrappedParts.add(np);
  -		}
  -
  -		return unWrappedParts;
  +		return ProviderUtils.unWrapPart(p, def);
   	}
  -	
  +
   	/**
   	 * Gets the WSIF WSDL Extensions Registry
   	 * This calls initializeProviders to ensure all providers
  
  
  
  1.4       +108 -0    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProviderUtils.java	10 Jan 2003 11:12:03 -0000	1.3
  +++ ProviderUtils.java	27 Feb 2003 15:46:30 -0000	1.4
  @@ -58,8 +58,20 @@
   package org.apache.wsif.providers;
   
   import java.lang.reflect.Array;
  +import java.util.ArrayList;
  +import java.util.List;
  +
  +import javax.wsdl.Definition;
  +import javax.wsdl.Part;
  +import javax.xml.namespace.QName;
   
   import org.apache.wsif.WSIFException;
  +import org.apache.wsif.schema.ComplexType;
  +import org.apache.wsif.schema.ElementType;
  +import org.apache.wsif.schema.Parser;
  +import org.apache.wsif.schema.SequenceElement;
  +
  +import com.ibm.wsdl.PartImpl;
   
   /**
    * A class of static utility methods for use across multiple providers
  @@ -301,4 +313,100 @@
   			return null;
   		}
   	}   	
  +
  +	/**
  +	 * Unwraps a wrapped DocLit style part.
  +	 */
  +	public static List unWrapPart(Part p, Definition def) throws WSIFException {
  +
  +		ArrayList l = new ArrayList();
  +		Parser.getAllSchemaTypes(def, l, null);
  +		if (l == null || l.size()<1) {
  +			throw new WSIFException("no schema elements found");
  +		}
  +
  +	    QName partQN = p.getElementName();
  +		if (partQN == null) {
  +			throw new WSIFException("part has no QName");
  +		}
  +	    
  +		ElementType et = getElementType(l, partQN);
  +		if (et == null) {
  +			throw new WSIFException("no ElementType found for part: " + p);
  +		}
  +
  +	    ArrayList unWrappedParts = new ArrayList();
  +	    
  +   		List children = et.getChildren();
  +	    ComplexType ct = null;
  +    	if (children == null || children.size() < 1) {
  +       	    ct = getComplexType(l, et.getElementType() );
  +	    } else {
  +	        ct = (ComplexType) children.get(0);
  +    	}
  +        if (ct == null) {
  +	        throw new WSIFException("cannot find complex type from ElementType: " + et);
  +        }
  +    	
  +   	    SequenceElement[] se = ct.getSequenceElements();
  +        if (se == null) {
  +	        throw new WSIFException("no sequence elements found on: " + ct);
  +        }
  +	    for (int i=0; i< se.length; i++) {
  +	       PartImpl np = new PartImpl();
  +	       QName type = se[i].getTypeName();
  +	       if (type==null) {
  +		       throw new WSIFException("sequence element has no type name: " + se[i]);
  +	       }
  +	       np.setName(type.getLocalPart());
  +	       np.setElementName(se[i].getElementType());
  +	       if (np.getElementName() == null) {
  +    	       np.setTypeName(se[i].getTypeName());
  +	       }
  +	       unWrappedParts.add(np);
  +	    }
  +
  +		return unWrappedParts;
  +	}
  +
  +    private static ElementType getElementType(List l, QName qn) {
  +    	ElementType et = null;
  +		for (int i=0; i<l.size() && et==null; i++ ){
  +			Object o = l.get(i);
  +			if ( o instanceof ElementType ) {
  +                QName etQN = ((ElementType)o).getTypeName();
  +				if ( qn.equals(etQN) ){
  +					et = (ElementType)o;
  +				}
  +			}
  +		}
  +		return et;
  +    }
  +	
  +    private static ComplexType getComplexType(List l, QName type) {
  +       	ComplexType ct = null;
  +    	if (type != null && l != null) {
  +    		String name = type.getLocalPart();
  +	    	for (int i=0; i<l.size() && ct==null; i++ ) {
  +		    	Object o = l.get(i);
  +			    if (name.equals(  ((ComplexType)o).getTypeName().getLocalPart() )){
  +				    ct = (ComplexType)o;
  +			    }
  +		    }
  +    	}
  +		return ct;
  +    }
  +
  +    /**
  +     * Gets the type of a Part, if the Part doesn't have a type,
  +     * then gets the Element name as WSIF treats this as the same thing.
  +     */
  +    public static QName getPartType(Part p) {
  +		QName type = p.getTypeName();
  +		if (type == null) {
  +			type = p.getElementName();
  +		}
  +		return type;
  +    }
  +
   }
  
  
  

Mime
View raw message