axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whitl...@apache.org
Subject cvs commit: xml-axis-wsif/java/test/proposals/mime MimeTest.java MimeImpl.java WSIFOperation_ApacheAxis.java
Date Mon, 21 Oct 2002 13:56:53 GMT
whitlock    2002/10/21 06:56:53

  Modified:    java/test/proposals/mime MimeTest.java MimeImpl.java
                        WSIFOperation_ApacheAxis.java
  Log:
  Receive mime attachments
  
  Revision  Changes    Path
  1.4       +4 -8      xml-axis-wsif/java/test/proposals/mime/MimeTest.java
  
  Index: MimeTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/proposals/mime/MimeTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MimeTest.java	21 Oct 2002 09:48:18 -0000	1.3
  +++ MimeTest.java	21 Oct 2002 13:56:53 -0000	1.4
  @@ -144,14 +144,10 @@
        * }
        */
   
  -//    public void testAxisReceiveSync() {
  -//        doit("SOAPPort", RECEIVE, SYNC);
  -//    }
  -//
  -//    public void testAxisJmsReceiveSync() {
  -//        doit("SOAPJMSPort", RECEIVE, SYNC);
  -//    }
  -//
  +    public void testAxisReceiveSync() {
  +        doit("SOAPPort", RECEIVE, SYNC);
  +    }
  +
       private void doit(String portName, String cmd, boolean blocking) {
   
           WSIFDynamicProvider_ApacheAxis provider =
  
  
  
  1.3       +16 -14    xml-axis-wsif/java/test/proposals/mime/MimeImpl.java
  
  Index: MimeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/proposals/mime/MimeImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MimeImpl.java	21 Oct 2002 09:48:18 -0000	1.2
  +++ MimeImpl.java	21 Oct 2002 13:56:53 -0000	1.3
  @@ -71,8 +71,6 @@
    */
   public class MimeImpl implements Mime {
   	
  -	private final String tempFileName = "MimeImplBackendFile.txt";
  -	
       public String fileToString(DataHandler dh) {
           try {
               InputStream is = dh.getInputStream();
  @@ -87,24 +85,28 @@
   
       public DataHandler stringToFile(String buff) {
           try {
  -            FileDataSource fds = new FileDataSource(tempFileName);
  -            File f = fds.getFile();
  -            if (f.exists()) {
  -                System.out.println("Deleting an existing file");
  -                f.delete();
  -            }
  -                
  -            if (!f.createNewFile()) {
  -                System.out.println("Failed to create file");
  -                return null;
  -            }
  +//            FileDataSource fds = new FileDataSource(tempFileName);
  +//            File f = fds.getFile();
  +//            if (f.exists()) {
  +//                System.out.println("Deleting an existing file");
  +//                f.delete();
  +//            }
  +//                
  +//            if (!f.createNewFile()) {
  +//                System.out.println("Failed to create file");
  +//                return null;
  +//            }
   
  -            fds = new FileDataSource(tempFileName);
  +            File f = File.createTempFile("WSIFMimeTest","txt");
  +            f.deleteOnExit();
  +
  +            FileDataSource fds = new FileDataSource(f.getAbsolutePath());
               fds.getOutputStream().write(buff.getBytes());
   
               DataHandler dh = new DataHandler(fds);
               return dh;
           } catch (IOException ioe) {
  +        	ioe.printStackTrace();
               return null;
           }
       }
  
  
  
  1.3       +76 -42    xml-axis-wsif/java/test/proposals/mime/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/proposals/mime/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFOperation_ApacheAxis.java	15 Oct 2002 13:55:31 -0000	1.2
  +++ WSIFOperation_ApacheAxis.java	21 Oct 2002 13:56:53 -0000	1.3
  @@ -73,6 +73,8 @@
   import javax.wsdl.Output;
   import javax.wsdl.Part;
   import javax.xml.namespace.QName;
  +import javax.xml.soap.AttachmentPart;
  +import javax.xml.soap.SOAPException;
   
   import org.apache.axis.AxisFault;
   import org.apache.axis.Message;
  @@ -515,55 +517,87 @@
       /**
        * Populate the outMessage with the response return value.
        */
  -    private void populateOutMsgReturnPart(Object resp, WSIFMessage outMsg) 
  -                                      throws WSIFException{
  -       if (outMsg != null ) {
  -          if ( returnName != null ) { 
  -             if ( resp == null ) {
  -                throw new WSIFException( 
  -                   "return value not found in response message" ); 
  -             } else if ( returnType != null // will be null for async responses
  -             && !returnType.isPrimitive()
  -             && !(returnType.isAssignableFrom( resp.getClass() )) ) {
  -                throw new WSIFException(
  -                "return value "
  -                + resp
  -                + " has unexpected type "
  -                + resp.getClass()
  -                + " instead of "
  -                + returnType);
  -             }
  -             outMsg.setObjectPart( returnName, resp );
  -          }
  -       }
  +    private void populateOutMsgReturnPart(Object resp, WSIFMessage outMsg)
  +        throws WSIFException {
  +        if (outMsg != null) {
  +            if (returnName != null) {
  +                if (resp == null)
  +                    throw new WSIFException(
  +                        "return value not found in response message");
  +
  +                setMessagePart(outMsg, returnName, resp, returnType);
  +            }
  +        }
       }
   
       /**
        * Populate the outMessage with the expected parts.
        * (this only does the out parameters not the return part)
        */
  -    private void populateOutMsgParts(WSIFMessage outMsg) 
  -                                      throws WSIFException{
  -       if ( outMsg != null ) {
  -          HashMap respParms = getResponseMsgParams();
  -          ArrayList wsdlOutParams = getWSDLOutParams();
  -          if ( respParms != null ) {
  -           	 String name;
  -             Object value;
  -             for (Iterator i = respParms.keySet().iterator(); i.hasNext(); ) {
  -                name = (String) i.next();
  -                value = respParms.get( name );
  -                outMsg.setObjectPart( name, value ); 	
  -                wsdlOutParams.remove( name );
  -             }
  -          }
  -          // init any other parts to null
  -          for (Iterator i=wsdlOutParams.iterator(); i.hasNext(); ) {
  -             outMsg.setObjectPart( (String) i.next(), null );
  -          }
  -       }
  +    private void populateOutMsgParts(WSIFMessage outMsg) throws WSIFException {
  +        if (outMsg != null) {
  +            HashMap respParms = getResponseMsgParams();
  +            ArrayList wsdlOutParams = getWSDLOutParams();
  +            if (respParms != null) {
  +                String name;
  +                Object value;
  +                for (Iterator i = respParms.keySet().iterator();
  +                    i.hasNext();
  +                    ) {
  +                    name = (String) i.next();
  +                    value = respParms.get(name);
  +                    setMessagePart(outMsg, name, value, value.getClass());
  +                    wsdlOutParams.remove(name);
  +                }
  +            }
  +            // init any other parts to null
  +            for (Iterator i = wsdlOutParams.iterator(); i.hasNext();) {
  +                outMsg.setObjectPart((String) i.next(), null);
  +            }
  +        }
       }
  -    
  +
  +    private static void setMessagePart(
  +        WSIFMessage msg,
  +        String name,
  +        Object value,
  +        Class type)
  +        throws WSIFException {
  +        Trc.entry(null, msg, name, value, type);
  +
  +        if (DataHandler.class.equals(type)
  +            && AttachmentPart.class.isAssignableFrom(value.getClass())) {
  +            AttachmentPart ap = (AttachmentPart) value;
  +            try {
  +                DataHandler dh = ap.getDataHandler();
  +                msg.setObjectPart(name, dh);
  +            } catch (SOAPException se) {
  +                Trc.exception(se);
  +                throw new WSIFException(
  +                    "WSIFOperation_ApacheAxis.setMessagePart messageName="
  +                        + (msg.getName() == null ? "null" : msg.getName())
  +                        + " partName="
  +                        + name
  +                        + "  caught "
  +                        + se);
  +            }
  +        } else if (
  +            type != null // will be null for async responses
  +                && !type.isPrimitive()
  +                && !(type.isAssignableFrom(value.getClass()))) {
  +            throw new WSIFException(
  +                "return value "
  +                    + value
  +                    + " has unexpected type "
  +                    + value.getClass()
  +                    + " instead of "
  +                    + type);
  +        } else
  +            msg.setObjectPart(name, value);
  +
  +        Trc.exit();
  +    }
  +        
       public boolean executeRequestResponseOperation(
           WSIFMessage wsifmessage,
           WSIFMessage wsifmessage1,
  
  
  

Mime
View raw message