Introduction

Service-clients and service-providers are often facing the need for transmitting both binary content and text data in a reliable and efficient way.

This document presents implementation outlines for this scenario. The service-provider has been implemented using the Oracle Service Bus (version 11.1.1.7) while the service-client has been realized using SOAPUI.

W3C Notes and Recommendations.

This document follows the documents SOAP Messages with Attachments: W3C Note 11 December 2000 and the SOAP Message Transmission Optimization Mechanism: W3C Recommendation – 25 January 2005 that describe standards on SOAP Message Transmission.

SOAP-with-Attachments (SwA)

The „SOAP Messages with Attachments: W3C Note 11 December 2000“ states:

„This document defines a binding for a SOAP 1.1 message to be carried within a MIME multipart/related message in such a way that the processing rules for the SOAP 1.1 message are preserved. The MIME multipart mechanism for encapsulation of compound documents can be used to bundle entities related to the SOAP 1.1 message such as attachments. Rules for the usage of URI references to refer to entities bundled within the MIME package are specified.“

 swa

Implementation

Service Provider

We define the xml schema as follows:



  
  
  
    
      
      
      
    
  

  
    
      
    
  


  
  
    
      
      
      
    
  
    

We use a file adapter for saving the attachment. Since the file adapter needs a base64-encoded-string we have to use a Java Callout to encode the byte array from:

$attachments/ctx:attachment/ctx:body/ctx:binary-content

The result string will be passed straight forward to the file adapter.

Service Client

For the Service-Client we use a default request from SOAPUI.

Example:
Request


   
   
      
         
            MASTERING_BLOCKCHAIN.pdf
            /home/oracle/Downloads/
            some text
         
      
   

Response:


   
   
      
         MASTERING_BLOCKCHAIN.pdf
         ok
         some text. Message contains 1 attachment
      
   

Load Tests

The detailed results:

Various files (pdf, zip, docx, etc.) have been transmitted, with a total of 137 MB. The mean total time was 23 sec., which means an average throughput of 5,9MB/sec.

Attachments over 70 MB were rejected by an Out-Of-Memory Exception.

swa_kpi

SOAP Message Transmission Optimization Mechanism (MTOM)

MTOM optimizes element content that is in the canonical lexical representation of the xsd:base64Binary data type.

Implementation

Service Provider

We define the xml schema as follows:



    
    
    
    
        
            
            
            
        
    

    
        
            
            
        
    

    
    
        
            
            
            
        
    
    

We use a file adapter for saving the attachment. Since the file adapter needs a base64-encoded-string we have to use a Java Callout to encode the byte array from
$body/mtom:payload/mtom:document/ctx:binary-content

The result will be passed straight forward to the file adapter.

Service Client

In SOAPUI we create a Request and we enable the MTOM parameter

mtom-enable

Example:

Request


   
   
      
         
            MASTERING_BLOCKCHAIN.pdf
            /home/oracle/Downloads/
            some Text
         
         cid:9781787125445-MASTERING_BLOCKCHAIN.pdf
      
   

Response:


   
   
      
         MASTERING_BLOCKCHAIN.pdf
         ok
         some Text
      
   

Load-Tests

The detailed results:

Various files (pdf, zip, docx, etc.) have been transmitted, with a total of 137 MB. The mean total time was 15 sec., which means an average throughput of 9.1 MB/sec.
Attachments over 70 MB were rejected by an out-of-Memory Exception.

mtom_kpi

Simple base64 Java Encoder

The following code for the java base64-encoder can be used by the Java Callout

package de.svi.att.tools;
import weblogic.utils.encoders.BASE64Encoder;
public class SVIBase64Encoder{
  public static String encode(byte[] bytes){
    BASE64Encoder encoder = new BASE64Encoder();
    String encodedString = encoder.encodeBuffer(bytes);
    return encodedString;
  }
}

Conclusion

We have implemented a client using SOAPUI and a service provider using OSB and a VM with the oracle SOA Suite Appliance 11.1.1.7 in order to compare the methods SwA and MTOM.

The MTOM mechanism has a performance advantage of 15%-30% compared to the SwA method.

None of the load tests led to a drop of server-performance due to garbage collection actions.

No Problems when dealing with special characters have been observed.

Alle Beiträge von Apostolos Varsamis

Schreibe einen Kommentar