axis-java-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/format WSIFFormatHandler.java
Date Thu, 01 Aug 2002 11:24:07 GMT
antelder    2002/08/01 04:24:07

  Modified:    java/src/org/apache/wsif/providers/jms JMSMessage.java
                        WSIFOperation_Jms.java
                        PrimitiveTypeFormatHandler.java
               java/src/org/apache/wsif/format/jms JMSFormatHandler.java
               java/src/org/apache/wsif/format WSIFFormatHandler.java
  Log:
  Tidy up and fix various problems with the native JMS provider.
  
  Revision  Changes    Path
  1.11      +60 -38    xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java
  
  Index: JMSMessage.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JMSMessage.java	26 Jul 2002 10:52:03 -0000	1.10
  +++ JMSMessage.java	1 Aug 2002 11:24:06 -0000	1.11
  @@ -232,6 +232,7 @@
   				org.apache.wsif.format.jms.JMSFormatHandler fh = getFormatHandler(partName);	
   
   				if (fh != null) {
  +					fh.setPartQName(partQName);
   					fh.setObjectPart(parts.get(partName));
   					fh.write(message);
   				}	
  @@ -275,6 +276,7 @@
   					org.apache.wsif.format.jms.JMSFormatHandler fh = getFormatHandler(partName);
   
   					if (fh != null) {
  +						fh.setPartQName(partQName);
   						fh.setObjectPart(parts.get(partName));
   
   						// Send the message since it is the native format
  @@ -361,6 +363,7 @@
   				org.apache.wsif.format.jms.JMSFormatHandler fh = getFormatHandler(partName);	
   
   				if (fh != null) {
  +					fh.setPartQName(partQName);
   					fh.setObjectPart(parts.get(partName));
   					fh.write(message);
   				}	
  @@ -392,6 +395,7 @@
   					org.apache.wsif.format.jms.JMSFormatHandler fh = getFormatHandler(partName);	
   
   					if (fh != null) {
  +						fh.setPartQName(partQName);
   						fh.setObjectPart(parts.get(partName));
   						fh.write(message);
   						result.put(partName, message.getObject());
  @@ -475,7 +479,7 @@
   				wsifFormat = true;
   
                   // Need to make the message mutable
  -                message.clearBody();
  +                //message.clearBody();
   
                   // Parse the document ignoring the document element which should be the
message name
                   // The contents should represent the parts as elements
  @@ -484,7 +488,7 @@
                       n = n.getNextSibling()) {
                       if (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
                           String partName = n.getLocalName();
  -
  +/*
                           java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
   
                           org.apache.xml.serialize.OutputFormat format =
  @@ -502,15 +506,18 @@
                           // Get the contents
                           String partText = os.toString();
                           //String partContents = partText.substring(partText.indexOf(">")
+1, partText.lastIndexOf("<"));
  -
  +*/
                           javax.wsdl.Part partModel = fieldMessageModel.getPart(partName);
                           org.apache.wsif.format.jms.JMSFormatHandler fh = getFormatHandler(partName);
   
                           if (fh != null) {
   
  -                            message.setText(partText);
  -                            fh.read(message);
  +                            //message.setText(partText);
  +                            //fh.read(message);
   
  +							fh.setPartQName(new javax.xml.namespace.QName(fieldMessageModel.getQName().getNamespaceURI(),
partModel.getName()));
  +							fh.setObjectPart(n);
  +							
                               setObjectPart(partName, fh.getObjectPart());
   
                               // ?? Do I want to store the format handler instead???
  @@ -518,13 +525,26 @@
   
                           } else {
                               // No format handler - pass the part contents directly
  +							java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
  +				
  +							org.apache.xml.serialize.OutputFormat format = new org.apache.xml.serialize.OutputFormat();
  +							org.apache.xml.serialize.TextSerializer serializer = new org.apache.xml.serialize.TextSerializer();
  +							serializer.setOutputFormat(format);
  +							serializer.setOutputByteStream(os);
  +		
  +	 						format.setOmitXMLDeclaration(true);
  +	
  +							serializer.serialize((org.w3c.dom.Element)n);
  +							os.flush();
  +							// Get the contents
  +							String partText = os.toString(); 
                               setObjectPart(partName, partText);
                           }
                       }
                   }
   
                   // Reset the message to original text
  -                message.setText(text);
  +                //message.setText(text);
                   }
           }
   		catch (JMSException e) {
  @@ -540,43 +560,44 @@
   			// For all other exceptions ignore since it is likely due to parsing of a non-XML document
   		}
   
  -		if (!wsifFormat) {
  -			// Unknown format - either XML or Text
  -			// Pass the contents of the message to each part of the message model 
  -			Object[] partNames = fieldMessageParts != null ? 
  -				fieldMessageParts.toArray() :
  -				fieldMessageModel.getParts().keySet().toArray();
  +		try {
  +			if (!wsifFormat) {
  +				// Unknown format - either XML or Text
  +				// Pass the contents of the message to each part of the message model 
  +				Object[] partNames = fieldMessageParts != null ? 
  +					fieldMessageParts.toArray() :
  +					fieldMessageModel.getParts().keySet().toArray();
   			
  -			// should only be one part
  -			if (partNames.length != 1)
  -				throw new WSIFException(
  -					"There should only be one part defined in " + fieldMessageModel.getQName().getLocalPart());

  +				// should only be one part
  +				if (partNames.length != 1)
  +					throw new WSIFException(
  +						"There should only be one part defined in " + fieldMessageModel.getQName().getLocalPart());

   					
  -			String partName = partNames[0].toString();
  +				String partName = partNames[0].toString();
   			
  -			javax.wsdl.Part partModel = fieldMessageModel.getPart(partName);
  -			JMSFormatHandler fh = getFormatHandler(partName);
  +				javax.wsdl.Part partModel = fieldMessageModel.getPart(partName);
  +				JMSFormatHandler fh = getFormatHandler(partName);
   								
  -			if (fh != null) {
  -				fh.read(message);
  +				if (fh != null) {
  +					fh.setPartQName(new javax.xml.namespace.QName(fieldMessageModel.getQName().getNamespaceURI(),
partModel.getName()));
  +					fh.read(message);
   					
  -				setObjectPart(partName, fh.getObjectPart());
  +					setObjectPart(partName, fh.getObjectPart());
   					
  -				// ?? Do I want to store the format handler instead???
  -				//partToFHMap.put(partKey, formatHandler);
  +					// ?? Do I want to store the format handler instead???
  +					//partToFHMap.put(partKey, formatHandler);
   			
  -			}
  -			else {
  -				try {
  +				}
  +				else {
   					// No format handler - pass the part contents directly
   					setObjectPart(partName, message.getText());
   				}
  -				catch (JMSException e) {
  -					Trc.exception(e);
  -					throw new WSIFException("Error in read.", e);
  -				}
   			}
  -		}	
  +		}
  +		catch (JMSException e) {
  +			Trc.exception(e);
  +			throw new WSIFException("Error in read.", e);
  +		}			
   		Trc.exit();
   	}	
   
  @@ -607,7 +628,7 @@
               if (object instanceof java.util.Map
                   && ((java.util.Map) object).containsKey(partNames[0])) {
                   // Need to make the message mutable			
  -                message.clearBody();
  +                //message.clearBody();
   
                   java.util.Map map = (java.util.Map) object;
   
  @@ -622,9 +643,10 @@
                           if (fh != null) {
   
                               // Should be serializable since retrieved it over the wire
  -                            message.setObject((java.io.Serializable) map.get(partName));
  -                            fh.read(message);
  -
  +							//message.setObject((java.io.Serializable)map.get(partName));
  +							//fh.read(message);
  +							fh.setPartQName(new javax.xml.namespace.QName(fieldMessageModel.getQName().getNamespaceURI(),
partModel.getName()));
  +							fh.setObjectPart(map.get(partName));
                               setObjectPart(partName, fh.getObjectPart());
   
                               // ?? Do I want to store the format handler instead???
  @@ -638,7 +660,7 @@
   
                   }
                   // Reset the message to original text
  -                message.setObject((java.io.Serializable) object);
  +                //message.setObject((java.io.Serializable) object);
               } else {
                   // It is an unknown format
   				// Pass the contents of the message to each part of the message model 
  @@ -656,7 +678,7 @@
   				JMSFormatHandler fh = getFormatHandler(partName);
   								
   				if (fh != null) {
  -		
  +					fh.setPartQName(new javax.xml.namespace.QName(fieldMessageModel.getQName().getNamespaceURI(),
partModel.getName()));		
   					fh.read(message);
   					
   					setObjectPart(partName, fh.getObjectPart());
  
  
  
  1.17      +84 -20    xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
  
  Index: WSIFOperation_Jms.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WSIFOperation_Jms.java	29 Jul 2002 15:05:31 -0000	1.16
  +++ WSIFOperation_Jms.java	1 Aug 2002 11:24:06 -0000	1.17
  @@ -57,21 +57,23 @@
   
   package org.apache.wsif.providers.jms;
   
  -import java.util.List;
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.List;
   
  -import javax.jms.Message;
   import javax.wsdl.BindingOperation;
  -import javax.wsdl.BindingOutput;
  +import javax.wsdl.Input;
  +import javax.wsdl.Message;
   import javax.wsdl.Operation;
  -import javax.wsdl.Port;
  +import javax.wsdl.Output;
   import javax.wsdl.Service;
   import javax.wsdl.extensions.ExtensibilityElement;
   import javax.xml.namespace.QName;
   
   import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFCorrelationId;
  +import org.apache.wsif.WSIFCorrelationService;
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFMessage;
   import org.apache.wsif.WSIFOperation;
  @@ -81,19 +83,18 @@
   import org.apache.wsif.base.WSIFDefaultOperation;
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
  -import org.apache.wsif.WSIFCorrelationService;
   import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import org.apache.wsif.util.WSIFProperties;
   import org.apache.wsif.util.jms.WSIFJMSCorrelationId;
   import org.apache.wsif.util.jms.WSIFJMSDestination;
   import org.apache.wsif.util.jms.WSIFJMSFinder;
  +import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
   import org.apache.wsif.wsdl.extensions.jms.JMSBinding;
   import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
   import org.apache.wsif.wsdl.extensions.jms.JMSInput;
   import org.apache.wsif.wsdl.extensions.jms.JMSOutput;
   import org.apache.wsif.wsdl.extensions.jms.JMSProperty;
   import org.apache.wsif.wsdl.extensions.jms.JMSPropertyValue;
  -import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
   
   /**
    * WSIFOperation_Jms
  @@ -403,10 +404,13 @@
            * set the parts onto the message
            */
           // The input message parts can either be a jms property
  -        // or an input part. If an input part, that part will
  -        // only be used if there is not a jms:input atribute,
  -        // or the part name is in the jms:input list 
  +        // or an input part. Input parts not defined in the
  +        // WSDL will be ignored. Input parts will only be used
  +        // if there is not a jms:input atribute, or the part 
  +        // name is in the jms:input list. Parts defined in the
  +        // WSDL but not in the input message defualt to null. 
           String partName;
  +        ArrayList wsdlInputParts = getWSDLInputPartNames();
           HashMap propertyParts = getPropertyParts();
   	    WSIFMessage message = createInputMessage();
           for (Iterator i = input.getPartNames(); i.hasNext(); ) {
  @@ -415,12 +419,20 @@
                 jmsDest.setProperty(
                    (String)propertyParts.get( partName ), 
                    input.getObjectPart(partName) );
  -           } else if ( fieldInput == null ) { 
  -		      message.setObjectPart(partName, input.getObjectPart(partName));
  -           } else if ( fieldInput.getParts().contains( partName ) ) { 
  -		      message.setObjectPart(partName, input.getObjectPart(partName));
  +           } else if ( wsdlInputParts.contains( partName ) ) {
  +              wsdlInputParts.remove( partName );
  +           	  if ( fieldInput == null ) { 
  +		         message.setObjectPart(partName, input.getObjectPart(partName));
  +              } else if ( fieldInput.getParts().contains( partName ) ) { 
  +		         message.setObjectPart(partName, input.getObjectPart(partName));
  +              }
              }
           }
  +        
  +        // default missing parts to null
  +        for (Iterator i=wsdlInputParts.iterator(); i.hasNext(); ) {
  +           message.setObjectPart( (String) i.next(), null );
  +        }
   
           Service serviceModel = null;
           for (Iterator i =
  @@ -472,13 +484,29 @@
           WSIFResponse resp =
               formatter.unformatResponse((javax.jms.Message) responseObject);
   
  -        formatter.copyTo(resp.getOutgoingMessage(), output);
           formatter.copyTo(resp.getFaultMessage(), fault);
  +        
  +        // the output message contains all response parts
  +        // even if not defined in the WSDL. Any parts
  +        // defined in the WSDL but not in the response
  +        // default to null
  +        ArrayList wsdlOutputParts = getWSDLOutputPartNames();
  +        WSIFMessage m = resp.getOutgoingMessage();
  +        if ( m != null ) {
  +           String partName;
  +           for (Iterator i = m.getPartNames(); i.hasNext();) {
  +              partName = (String) i.next();
  +              output.setObjectPart( partName, m.getObjectPart(partName) );
  +              wsdlOutputParts.remove( partName );
  +           }
  +        }
  +        for (Iterator i = wsdlOutputParts.iterator(); i.hasNext(); ) {
  +           output.setObjectPart( (String) i.next(), null );
  +        }
   
           /**
            * Need to retrieve the header, property values from the JMS Message and assign
them to WSIFMessage
            */
  -
   		//setOutProperties( jmsDest, output ); TODO output properties
   
       }
  @@ -492,11 +520,13 @@
       	HashMap propertyParts = new HashMap();
       	
       	// the input message properties
  -    	for (Iterator i=fieldInputJmsProperties.keySet().iterator();i.hasNext(); ) {
  -    		String propertyName = (String)i.next();
  -    		propertyParts.put(
  -    		   propertyName,
  -    		   fieldInputJmsProperties.get( propertyName ) );
  +    	if ( fieldInputJmsProperties != null ) {
  +    	   for (Iterator i=fieldInputJmsProperties.keySet().iterator();i.hasNext(); ) {
  +    		  String propertyName = (String)i.next();
  +    		  propertyParts.put(
  +    		     propertyName,
  +    		     fieldInputJmsProperties.get( propertyName ) );
  +    	   }
       	}
       	
       	return propertyParts;
  @@ -810,6 +840,40 @@
           if (jmsProps.size() > 0) {
               dest.setProperties(jmsProps);
           }
  +    }
  +
  +    private ArrayList getWSDLInputPartNames() {
  +       ArrayList wsdlInputParts = new ArrayList();
  +       Input wsdlInput = fieldOperation.getInput();
  +       if ( wsdlInput != null ) {
  +          Message inputMessage = wsdlInput.getMessage();
  +          String partName;
  +          for (Iterator i=inputMessage.getParts().keySet().iterator(); i.hasNext(); ) {
  +          	 partName = (String) i.next();
  +          	 if ( fieldInputJmsProperties == null 
  +          	 || !fieldInputJmsProperties.containsKey( partName ) ) {
  +                wsdlInputParts.add( partName );
  +          	 } 
  +          }
  +       }
  +       return wsdlInputParts;
  +    }
  +
  +    private ArrayList getWSDLOutputPartNames() {
  +       ArrayList wsdlOutputParts = new ArrayList();
  +       Output wsdlOutput = fieldOperation.getOutput();
  +       if ( wsdlOutput != null ) {
  +          Message outputMessage = wsdlOutput.getMessage();
  +          String partName;
  +          for (Iterator i=outputMessage.getParts().keySet().iterator(); i.hasNext(); )
{
  +             partName = (String) i.next();
  +          	 if ( fieldOutputProperties == null 
  +          	 || !fieldOutputProperties.containsKey( partName ) ) {
  +                wsdlOutputParts.add( partName ); 
  +          	 }
  +          }
  +       }
  +       return wsdlOutputParts;
       }
   
       public String deep() {
  
  
  
  1.5       +11 -7     xml-axis-wsif/java/src/org/apache/wsif/providers/jms/PrimitiveTypeFormatHandler.java
  
  Index: PrimitiveTypeFormatHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/PrimitiveTypeFormatHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PrimitiveTypeFormatHandler.java	19 Jul 2002 15:46:29 -0000	1.4
  +++ PrimitiveTypeFormatHandler.java	1 Aug 2002 11:24:06 -0000	1.5
  @@ -57,18 +57,13 @@
   
   package org.apache.wsif.providers.jms;
   
  -import java.io.Serializable;
  -import java.lang.reflect.Constructor;
   import java.text.DateFormat;
  -import java.text.ParseException;
   import java.text.SimpleDateFormat;
  -import java.util.Date;
  -import java.util.GregorianCalendar;
   
   import javax.jms.JMSException;
   import javax.jms.Message;
  -import javax.jms.ObjectMessage;
  -import javax.jms.TextMessage;
  +import javax.xml.namespace.QName;
  +
   import org.apache.wsif.format.jms.JMSFormatHandler;
   import org.apache.wsif.logging.Trc;
   
  @@ -81,6 +76,7 @@
       protected static DateFormat PRECISE_DATE_FORMAT =
           new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'");
   
  +    QName name;
       Object primitiveType;
       Class type;
       
  @@ -160,6 +156,10 @@
           return 0;
       }
   
  +	public QName getPartQName() {
  +		return name;
  +	}
  +
       public void setObjectPart(Object arg0) {
           primitiveType = arg0;
       }
  @@ -184,6 +184,10 @@
   
       public void setDoublePart(double arg0) {
       }
  +
  +	public void setPartQName(QName name) {
  +		this.name = name;
  +	}
   
       /**
        * @see JMSFormatHandler#write(Message)
  
  
  
  1.2       +3 -3      xml-axis-wsif/java/src/org/apache/wsif/format/jms/JMSFormatHandler.java
  
  Index: JMSFormatHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/format/jms/JMSFormatHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSFormatHandler.java	6 Jun 2002 08:28:50 -0000	1.1
  +++ JMSFormatHandler.java	1 Aug 2002 11:24:07 -0000	1.2
  @@ -63,8 +63,8 @@
   public interface JMSFormatHandler
       extends org.apache.wsif.format.WSIFFormatHandler {
   
  -    public void write(javax.jms.Message message);
  -
  -    public void read(javax.jms.Message message);
  +	public void write(javax.jms.Message message) throws javax.jms.JMSException;
  +	
  +	public void read(javax.jms.Message message) throws javax.jms.JMSException;
   
   }
  
  
  
  1.3       +5 -1      xml-axis-wsif/java/src/org/apache/wsif/format/WSIFFormatHandler.java
  
  Index: WSIFFormatHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/format/WSIFFormatHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFFormatHandler.java	14 Jun 2002 13:45:10 -0000	1.2
  +++ WSIFFormatHandler.java	1 Aug 2002 11:24:07 -0000	1.3
  @@ -57,7 +57,7 @@
   
   package org.apache.wsif.format;
   
  -import java.beans.PropertyChangeEvent;
  +import javax.xml.namespace.QName;
   
   /**
    * @author Owen Burroughs <owenb@apache.org>
  @@ -75,4 +75,8 @@
       public Object getObjectPart();
       public Object getObjectPart(Class sourceClass);
       public void setObjectPart(Object objectPart);
  +	
  +	public QName getPartQName();
  +    public void setPartQName(QName name);
  +    
   }
  
  
  

Mime
View raw message