Skip to Content

In

  my last blog “How-to create a web service with attachments (SOAP With Attachments)“,

  we generated a web service that

  takes binary data and use it with

  SOAP with attachments and said

  that we can use the standart way

  to pass the binary data also.

In

  this blog we will generate the

  standard web service without attachments,

  create a standalone proxy to test

  both services(SOAP with attachments

  and without attachments) and see

  the difference. By the way if

  we ask what’s the difference?

  The answer is the performance..

For
the second web service, we simply
generated the web service from
the same ejb method but this time
we use HTTP SOAP while configuring
the service. After creating the
two services, in order to see
the difference in SOAP messages,
call the web services with dummy
data from the web services navigator..

*First
SOAP with attachments, mime
request (1st web service):*


POST /SOAPWAttachWS/ConfigWAttachment?style=mime HTTP/1.1 Host: local.bb.name.tr:50000

Content-Type: multipart/related; type=”text/xml”;       

boundary=”—-=_Part_50_16915488.1173210608859″

Connection: close

Content-Length: 1094

SOAPAction: “”


=_Part_50_16915488.1173210608859

Content-type: text/xml


=_Part_50_16915488.1173210608859

Content-type: text/plain Content-ID: <1173210608859productName> Hammer


=_Part_50_16915488.1173210608859

Content-type: application/octetstream

Content-Transfer-Encoding: binary

Content-ID: <1173210608859productImage>


=_Part_50_16915488.1173210608859–

private static void testWithoutAttachment(){

    try{

     long s = System.currentTimeMillis();

     String readPath = “C:
BD.jpg”;

     SOAPWOAttachmentWSImpl service = new SOAPWOAttachmentWSImpl();

     ConfigWOAttachmentBindingStub  ws = (ConfigWOAttachmentBindingStub)

     service.getLogicalPort(ConfigWOAttachmentBindingStub.class);

     byte[] fileContent = readFile(readPath);

     String productName = “WOATTACH_”+new SimpleDateFormat(“ddMMyyyy_HHmmss”).format(new java.util.Date());

     String result = ws.registerProduct(productName,fileContent);

     long e = System.currentTimeMillis();

     System.out.print(“-testWithoutAttachment :”);

     System.out.println((e-s)); }

     catch (Exception e) {

     // XXX Auto-generated catch block

     e.printStackTrace();

     }

   }

  private static void testWithAttachment(){

     try{

          long s = System.currentTimeMillis();

          String readPath = “C:
BD.jpg”;

          SOAPWAttachWSImpl service = new sOAPWAttachWSImpl();

          ConfigWAttachmentBindingStub ws = (ConfigWAttachmentBindingStub) service.getLogicalPort(ConfigWAttachmentBindingStub.class);

          byte[] fileContent = readFile(readPath);

          String productName = “WITH_ATTACH_”+new SimpleDateFormat(“ddMMyyyy_HHmmss”).format(new java.util.Date());                          

          String result = ws.registerProduct(productName,fileContent);

          long e = System.currentTimeMillis();

          System.out.print(“-testWithAttachment :”);

          System.out.println((e-s));

     } catch (Exception e) {

     // XXX Auto-generated   catch block

          e.printStackTrace();

     }

  }

  private static byte[] readFile(String readPath) throws Exception {

   FileInputStream infile = new FileInputStream (readPath);

   int infilelength = infile.available();

   byte[] key = new byte[infilelength];

   infile.read (key);

   infile.close();

   return key;

  }

 

What
I did in this test is send a
binary data to my web services
n times, and measure the time
that passes between each request.

And
here are the test results for
10x Test:


testWithoutAttachment :16603


testWithoutAttachment :16540


testWithoutAttachment :20297


testWithoutAttachment :16430


testWithoutAttachment :16009


testWithoutAttachment :16071


testWithoutAttachment :16337


testWithoutAttachment :16697


testWithoutAttachment :16540


testWithoutAttachment :19029

****
testWithoutAttachment average:17


testWithAttachment :12268


testWithAttachment :12468


testWithAttachment :12459


testWithAttachment :12631


testWithAttachment :15038


testWithAttachment :13100


testWithAttachment :12553


testWithAttachment :12349


testWithAttachment :12475


testWithAttachment :12318

****
testWithAttachment average:12

In
order to get more accurate results
we should increase the number
of calls, however 10x is enough
for seeing the performance penalty
which is around 40%.

You can read more about web services in SDN:

  http://www.sdn.sap.com/irj/sdn?rid=/webcontent/uuid/fcbc97b6-0a01-0010-6594-f8208ff674f9

+Evaluation
of Web services attachments can
be followed with this link+

  http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3b28e590-0201-0010-968f-e10ed5328191

+Kevin’s
blogs are
other successful ones that talks
about standards +

  XOP, MTOM and web services attachments support – Part II

  WS-I reaches another  Web services interoperability milestone

And the standards’ body :W3C’s
SOAP

Messages with Attachments page

  http://www.w3.org/TR/SOAP-attachments  </p>

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member
    Baris,

    Any idea how to set up the user name / password for authentication if you are accessing a RFC exposed as a web service in case of standalone proxy? I am not able to find out the exact piece of code to do this..

    Regards,
    Amol Joshi

    (0) 
    1. Former Member Post author
      Amol,
      Adjust this code for your purpose:

      MyWSImpl service = new MyWSImpl();
                     BasicAuthBindingStub ws = (BasicAuthBindingStub) service.getLogicalPort(BasicAuthBindingStub.class);

                     SecurityProtocol sp = (SecurityProtocol) ws._getGlobalProtocols().getProtocol(“SecurityProtocol”);
                     AuthenticationContext ac = sp.getAuthenticationContext();
                     ac.setUsername(“myusername”);
                     ac.setPassword(“mypassword”);          
                     System.out.println(ws.showMeTheMoney(“BB”));

      (0) 

Leave a Reply