Hi list,

I'm playing with soap attachments in dime format using axis.
I want to measure performance between soap implementation and custom implementation i.e
sending binary fail over http. In my test case soap is about twise slower then plain http.
Could someone point mi a way of increasing soap performance - my test case follows up.


Thanks in advance
Milen

-----------------------------------------------------------------------
Soap service:

public class AttachmentService {

public DataHandler getDocument ( String fileName )
throws Exception
{
//explicitly set format to DIME, default is MIME
Message rspmsg = AxisEngine.getCurrentMessageContext().getResponseMessage();
rspmsg.getAttachmentsImpl().setSendType(org.apache.axis.attachments.Attachments.SEND_TYPE_DIME);


     DataHandler dh = new DataHandler(new FileDataSource(fileName));
     if (dh == null ) System.err.println("dhSource is null");
     return dh;
   }

}

Soap client:

public boolean requestAtt(String filename) throws Exception {

       //Create empty datahandler
       DataHandler dhSource = new DataHandler(new FileDataSource(""));
       String endpoint = "http://192.168.1.60:8080"; +
                        "/axis/services/AttachmentService";

       Service service = new Service();
       Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new URL(endpoint)); //Set the target service host and service location,
call.setOperationName(new QName("urn:AttachmentService", "getDocument")); //This is the target services method to invoke.
QName qnameAttachment = new QName("urn:AttachmentService", "DataHandler");


call.registerTypeMapping(dhSource.getClass(), //Add serializer for attachment.
qnameAttachment,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);


       call.addParameter("filename", XMLType.XSD_STRING,
                         ParameterMode.IN); //Add the filename.
       call.setReturnType(qnameAttachment);
       Object ret = call.invoke(new Object[]{
           filename
       }
       ); //Add the filename param.

DataHandler rdh = (DataHandler) ret;

if (receivedfileName == null) {
System.err.println("Could not get the file name.");
throw new AxisFault("", "Could not get the file name.", null, null);
}
File f = new File("/tmp/f");
FileOutputStream fos = new FileOutputStream(f);
fos.write(content);
return true;
}


and my custom method foe receiving a file

private void receive( String fileName )
         throws Exception
 {
   DataOutputStream  out;
   URL url = new URL(target);
   URLConnection connection = url.openConnection();
   HttpURLConnection hc = (HttpURLConnection)connection;
   hc.setRequestMethod("POST");
   hc.setDoOutput(true);
   hc.setAllowUserInteraction(true);
   out = new DataOutputStream(hc.getOutputStream());
   String s = "filename=" + fileName + "&method=getDocument";
   out.write(s.getBytes());
   out.flush();

   // read response
   InputStream is=hc.getInputStream();
   byte[] b = new byte[hc.getContentLength()];
   is.read(b);
   is.close();

   // write to file
   File f = new File("/tmp/rec.file");
   f.delete();
   FileOutputStream fos = new FileOutputStream(f);
   fos.write(b);
   fos.close();

}

Reply via email to