ws-wsif-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/src/org/apache/wsif/util/jms JMS2HTTPBridge.java
Date Fri, 14 Feb 2003 15:22:50 GMT
whitlock    2003/02/14 07:22:50

  Modified:    java/src/org/apache/wsif/util/jms JMS2HTTPBridge.java
  Log:
  Fix gump failure by using the DefaultSocketFactory instead of a SocketFactoryFactory
  
  Revision  Changes    Path
  1.11      +63 -19    xml-axis-wsif/java/src/org/apache/wsif/util/jms/JMS2HTTPBridge.java
  
  Index: JMS2HTTPBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/JMS2HTTPBridge.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JMS2HTTPBridge.java	12 Feb 2003 16:48:48 -0000	1.10
  +++ JMS2HTTPBridge.java	14 Feb 2003 15:22:49 -0000	1.11
  @@ -79,8 +79,8 @@
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
   import org.apache.axis.components.net.BooleanHolder;
  +import org.apache.axis.components.net.DefaultSocketFactory;
   import org.apache.axis.components.net.SocketFactory;
  -import org.apache.axis.components.net.SocketFactoryFactory;
   import org.apache.axis.encoding.Base64;
   import org.apache.axis.transport.http.ChunkedInputStream;
   import org.apache.axis.transport.http.HTTPConstants;
  @@ -326,8 +326,15 @@
                       String host = httpURL.getHost();
                       int port = httpURL.getPort();
   
  +                    // The SocketFactoryFactory.getFactory method has changed 
  +                    // signature between Axis 1.0 and Axis 1.1 so avoid its use
  +                    // by using DefaultSocketFactory instead. This prevents the
  +                    // bridge from using secure sockets.
  +                    // SocketFactory factory =
  +                    //     SocketFactoryFactory.getFactory(new Hashtable());
                       SocketFactory factory =
  -                        SocketFactoryFactory.getFactory(new Hashtable());
  +                        new DefaultSocketFactory(new Hashtable());
  +
                       Socket sock =
                           factory.create(host, port, otherHeaders, useFullURL);
   
  @@ -630,7 +637,7 @@
           .append(HTTPConstants.HEADER_ACCEPT_TEXT_ALL)
           .append("\r\n")
           .append(HTTPConstants.HEADER_USER_AGENT) //Tell who we are.
  -        .append(": ").append(Constants.AXIS_VERSION).append("\r\n").append(
  +        .append(": ").append("WSIF").append("\r\n").append(
               HTTPConstants.HEADER_HOST) //used for virtual connections
           .append(": ")
           .append(host)
  @@ -967,7 +974,7 @@
                   inp = new ChunkedInputStream(inp);
               }
   
  -            sendJmsReply(inp, contentType, contentLocation);
  +            sendJmsReply(inp, contentType, contentLocation, contentLength);
   
               //            outMsg = new Message( new SocketInputStream(inp, sock), false,
contentType,
               //                    contentLocation);
  @@ -1004,28 +1011,65 @@
       private void sendJmsReply(
           InputStream inp,
           String contentType,
  -        String contentLocation)
  +        String contentLocation,
  +        String contentLength)
           throws Exception {
           Trc.entry(this, inp, contentType, contentLocation);
   
  +        int cl = 0;
  +        try {
  +            cl = new Integer(contentLength).intValue();
  +        } catch (Exception e) {
  +            Trc.ignoredException(e);
  +        }
  +        
  +        byte[] buff = new byte[cl];
  +        int bytesRead = 0;
           int cnt = 0;
  -        while ((inp.available() == 0)
  -            && ((syncTimeout == 0) || (cnt * 100 < syncTimeout))) {
  +        while (bytesRead < cl) {
  +            int avail = inp.available();
  +            while ((avail == 0)
  +                && ((syncTimeout == 0) || (cnt * 100 < syncTimeout))) {
   
  -            if (verbose)
  -                System.out.println("wait " + cnt);
  -            cnt++;
  -            Thread.sleep(100);
  -        }
  +                if (verbose)
  +                    System.out.println("wait " + cnt);
  +                cnt++;
  +                Thread.sleep(100);
  +                avail = inp.available();
  +            }
   
  -        int avail = inp.available();
  -        if (verbose)
  -            System.out.println("JMS2HTTPBridge sendJmsReply avail=" + avail);
  -        byte[] buff = new byte[avail];
  -        inp.read(buff);
  +            if (cnt * 100 >= syncTimeout) {
  +                System.err.println(
  +                    "JMS2HTTPBridge timeout before reading complete "
  +                        + "message from socket. Bytes read="
  +                        + bytesRead);
  +                break;
  +            }
  +
  +            if (veryVerbose)
  +                System.out.println(
  +                    "JMS2HTTPBridge sendJmsReply avail="
  +                        + avail
  +                        + " bytesRead="
  +                        + bytesRead);
  +
  +//            byte[] tmp = new byte[avail];
  +//            inp.read(tmp);
  +//            for (int i=0; i<avail; i++) {
  +//            	buff[bytesRead+i] = tmp[i];
  +//            }
  +            
  +            inp.read(buff, bytesRead, avail);
  +            bytesRead += avail;
  +        }
  +        String sBuff = new String(buff);
  +        
           if (verbose)
               System.out.println(
  -                "JMS2HTTPBridge sendJmsReply buff=" + new String(buff));
  +                "JMS2HTTPBridge sendJmsReply len="
  +                    + sBuff.length()
  +                    + " buff="
  +                    + sBuff);
   
           // Put the properties from the received message onto the message we are 
           // about to send. Filter out everything but those properties that we 
  @@ -1054,7 +1098,7 @@
   
           destination.setProperties(kept);
           destination.setReplyToQueue((Queue) original.getJMSReplyTo());
  -        destination.send(new String(buff), original.getJMSMessageID());
  +        destination.send(sBuff, original.getJMSMessageID());
   
           Trc.exit();
       }
  
  
  

Mime
View raw message