Index: trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.java
===================================================================
--- trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.java	(revision 1992)
+++ trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.java	(revision 1993)
@@ -40,4 +40,5 @@
 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;
 import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType;
+import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType.CallType;
 
 /**
@@ -220,6 +221,6 @@
      * @return body of the SOAP event
      */
-    public static Element getSoapRequestBodyFromEvent(Event event) {
-        return getSoapRequestBodyFromEvent(event, false);
+    public static Element getSoapBodyFromEvent(Event event) {
+        return getSoapBodyFromEvent(event, false);
     }
 
@@ -235,5 +236,5 @@
      * @return body of the SOAP event
      */
-    public static Element getSoapRequestBodyFromEvent(Event event, boolean useRandomRequestBodies) {
+    public static Element getSoapBodyFromEvent(Event event, boolean useRandomRequestBodies) {
         Element requestBody = null;
         if (event.getType() instanceof SOAPEventType) {
@@ -242,8 +243,8 @@
         else if (event.getType() instanceof SimpleSOAPEventType) {
             if (useRandomRequestBodies) {
-                requestBody = ((SimpleSOAPEventType) event.getType()).getRandomSoapRequestBody();
+                requestBody = ((SimpleSOAPEventType) event.getType()).getRandomSoapMsgBody();
             }
             else {
-                requestBody = ((SimpleSOAPEventType) event.getType()).getSoapRequestBody();
+                requestBody = ((SimpleSOAPEventType) event.getType()).getSoapMsgBody();
             }
         }
@@ -382,5 +383,5 @@
                         new Event(new SimpleSOAPEventType(methodName, eventType.getServiceName(),
                                                           eventType.getClientName(),
-                                                          eventType.getSoapRequestBody(),
+                                                          eventType.getSoapMsgBody(),
                                                           eventType.getEqualSOAPDataMap()),
                                   event.getTarget());
@@ -457,15 +458,99 @@
         return sortedSequences;
     }
-    
+
+    /**
+     * <p>
+     * Sorts the sequences by the orderingId of the requests/responses. This function only supports
+     * the ordering of {@link Event}s with a {@link SOAPEventType}.
+     * </p>
+     * 
+     * @param sequences
+     *            sequences to be order
+     * @param orderType
+     *            determines if sequences are ordered by request or response
+     * @return sorted sequences
+     */
+    public static Collection<List<Event>> sortAndConvertSequences(Collection<List<Event>> sequences,
+                                                                  boolean keepRequests,
+                                                                  boolean keepResponse)
+    {
+        Collection<List<Event>> sortedSequences = new LinkedList<>();
+        EqualSOAPDataMap equalSOAPDataMap = new EqualSOAPDataMap();
+        for (List<Event> sequence : sequences) {
+            // use insertion sort
+            List<Event> sortedSequence = new LinkedList<>();
+            long lastOrderId = Long.MIN_VALUE;
+            long selectedOrderId;
+            Event selectedEvent;
+            CallType selectedCallType = CallType.RESPONSE;
+            do {
+                selectedEvent = null;
+                selectedOrderId = Long.MAX_VALUE;
+                for (Event event : sequence) {
+                    if (!(event.getType() instanceof SOAPEventType)) {
+                        throw new RuntimeException(
+                                                   "Can only order SOAPEventTypes. SimpleSOAPEvent is also not supported. Event type found: " +
+                                                       event.getType().getClass().getName());
+                    }
+                    SOAPEventType soapEventType = (SOAPEventType) event.getType();
+                    long requestOrderId = soapEventType.getExchange().getRequest().getOrderingId();
+                    long responseOrderId =
+                        soapEventType.getExchange().getResponse().getOrderingId();
+
+                    if (requestOrderId > lastOrderId && requestOrderId < selectedOrderId) {
+                        selectedOrderId = requestOrderId;
+                        selectedEvent = event;
+                        selectedCallType = CallType.REQUEST;
+                    }
+                    if (responseOrderId > lastOrderId && responseOrderId < selectedOrderId) {
+                        selectedOrderId = responseOrderId;
+                        selectedEvent = event;
+                        selectedCallType = CallType.RESPONSE;
+                    }
+                }
+                if (selectedEvent != null) {
+                    SOAPEventType eventType = (SOAPEventType) selectedEvent.getType();
+                    Element soapMsgBody;
+                    switch (selectedCallType)
+                    {
+                        case REQUEST:
+                            soapMsgBody = eventType.getSoapRequestBody();
+                            break;
+                        case RESPONSE:
+                            soapMsgBody = eventType.getSoapResponseBody();
+                            break;
+                        default:
+                            throw new RuntimeException("unsupported call type: " + selectedCallType);
+                    }
+                    if ((keepRequests && selectedCallType == CallType.REQUEST) ||
+                        (keepResponse && selectedCallType == CallType.RESPONSE))
+                    {
+                        sortedSequence.add(new Event(new SimpleSOAPEventType(eventType
+                            .getCalledMethod(), eventType.getServiceName(), eventType
+                            .getClientName(), soapMsgBody, equalSOAPDataMap, selectedCallType)));
+                    }
+                    lastOrderId = selectedOrderId;
+                }
+                
+            } while(selectedEvent!=null);
+            sortedSequences.add(sortedSequence);
+        }
+        return sortedSequences;
+    }
+
     /**
      * <p>
      * Removes calls to and from all ignored services from the sequences.
      * </p>
-     *
-     * @param sequences sequences where the ignored services are removed
-     * @param ignoredServicesString comma separted string that defines the ignored services
+     * 
+     * @param sequences
+     *            sequences where the ignored services are removed
+     * @param ignoredServicesString
+     *            comma separted string that defines the ignored services
      * @return sequences without events that reference the ignored services
      */
-    public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, String ignoredServicesString) {
+    public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences,
+                                                                       String ignoredServicesString)
+    {
         Set<String> ignoredServices = new HashSet<>();
         if (ignoredServicesString != null) {
@@ -476,15 +561,19 @@
         return removeCallsToIgnoredServices(sequences, ignoredServices);
     }
-    
+
     /**
      * <p>
      * Removes calls to and from all ignored services from the sequences.
      * </p>
-     *
-     * @param sequences sequences where the ignored services are removed
-     * @param ignoredServices set with all ignored service names
+     * 
+     * @param sequences
+     *            sequences where the ignored services are removed
+     * @param ignoredServices
+     *            set with all ignored service names
      * @return sequences without events that reference the ignored services
      */
-    public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences, Set<String> ignoredServices) {
+    public static Collection<List<Event>> removeCallsToIgnoredServices(Collection<List<Event>> sequences,
+                                                                       Set<String> ignoredServices)
+    {
         Collection<List<Event>> onlyAcceptedServicesSequences = new LinkedList<>();
         for (List<Event> sequence : sequences) {
@@ -493,5 +582,6 @@
                 SimpleSOAPEventType eventType = (SimpleSOAPEventType) event.getType();
                 if (!ignoredServices.contains(eventType.getServiceName()) &&
-                    !ignoredServices.contains(eventType.getClientName()) ) {
+                    !ignoredServices.contains(eventType.getClientName()))
+                {
                     onlyAcceptedServicesSequence.add(event);
                 }
Index: trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java
===================================================================
--- trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java	(revision 1992)
+++ trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java	(revision 1993)
@@ -270,4 +270,16 @@
         }
     }
+    
+    /**
+     * @return the body of the soapResponse
+     */
+    public Element getSoapResponseBody() {
+        try {
+            return soapResponse.getSOAPBody();
+        }
+        catch (SOAPException e) {
+            return null;
+        }
+    }
 
     /* (non-Javadoc)
Index: trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
===================================================================
--- trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java	(revision 1992)
+++ trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java	(revision 1993)
@@ -38,4 +38,15 @@
 public class SimpleSOAPEventType implements IEventType {
 
+    /**
+     * <p>
+     * Defines if this event represents an request or an response.
+     * </p>
+     * 
+     * @author Steffen Herbold
+     */
+    public enum CallType {
+        REQUEST, RESPONSE
+    }
+
     /**  */
     private static final long serialVersionUID = 1L;
@@ -65,13 +76,20 @@
     /**
      * <p>
-     * the body of the SOAP request; storage as serialized XML string to allow object serialization
-     * </p>
-     */
-    private final String soapRequestBody;
-    
-    /**
-     * TODO
-     */
-    private final EqualSOAPDataMap equalRequestsMap;
+     * the body of the SOAP message; storage as serialized XML string to allow object serialization
+     * </p>
+     */
+    private final String soapMsgBody;
+
+    /**
+     * <p>
+     * defines whether this event represents a request or a response
+     * </p>
+     */
+    private final CallType callType;
+
+    /**
+     * reference to the {@link EqualSOAPDataMap} associated with the sequence this event belongs to.
+     */
+    private final EqualSOAPDataMap equalBodyMap;
 
     /**
@@ -84,12 +102,12 @@
                                String serviceName,
                                String clientName,
-                               Element soapRequestBody)
+                               Element soapMsgBody)
     {
-        this(calledMethod, serviceName, clientName, soapRequestBody, null);
-    }
-    
-    /**
-     * <p>
-     * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 
+        this(calledMethod, serviceName, clientName, soapMsgBody, null, CallType.REQUEST);
+    }
+
+    /**
+     * <p>
+     * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap.
      * </p>
      * 
@@ -98,6 +116,23 @@
                                String serviceName,
                                String clientName,
-                               Element soapRequestBody,
+                               Element soapMsgBody,
                                EqualSOAPDataMap equalRequestsMap)
+    {
+        this(calledMethod, serviceName, clientName, soapMsgBody, equalRequestsMap,
+             CallType.REQUEST);
+    }
+
+    /**
+     * <p>
+     * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap.
+     * </p>
+     * 
+     */
+    public SimpleSOAPEventType(String calledMethod,
+                               String serviceName,
+                               String clientName,
+                               Element soapMsgBody,
+                               EqualSOAPDataMap equalRequestsMap,
+                               CallType callType)
     {
         if (calledMethod == null) {
@@ -113,8 +148,12 @@
         this.serviceName = serviceName;
         this.clientName = clientName;
-        this.soapRequestBody = SOAPUtils.getSerialization(soapRequestBody);
-        this.equalRequestsMap = equalRequestsMap;
-        if( equalRequestsMap!=null ) {
-            equalRequestsMap.add(this, this.soapRequestBody);
+        this.equalBodyMap = equalRequestsMap;
+        this.soapMsgBody = SOAPUtils.getSerialization(soapMsgBody);
+        this.callType = callType;
+
+        // this must be the last part of the constructor and only be called after all variables are
+        // initialized
+        if (equalRequestsMap != null) {
+            equalRequestsMap.add(this, this.soapMsgBody);
         }
     }
@@ -161,24 +200,37 @@
      * @return body of the SOAP request
      */
-    public Element getSoapRequestBody() {
-        return createDOMElement(soapRequestBody);
-    }
-    
-    /**
-     * <p>
-     * returns a randomly draw request body for the called method using {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)}
-     * </p>
-     *
+    public Element getSoapMsgBody() {
+        return createDOMElement(soapMsgBody);
+    }
+
+    /**
+     * <p>
+     * returns a randomly draw request body for the called method using
+     * {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)}
+     * </p>
+     * 
      * @return randomly drawn body of the SOAP request
      */
-    public Element getRandomSoapRequestBody() {
-        if( equalRequestsMap==null ) {
-            throw new RuntimeException("cannot use random mode is no request map is available; different data missing");
-        }
-        return createDOMElement(equalRequestsMap.getRandom(this));
-    }
-    
+    public Element getRandomSoapMsgBody() {
+        if (equalBodyMap == null) {
+            throw new RuntimeException(
+                                       "cannot use random mode is no request map is available; different data missing");
+        }
+        return createDOMElement(equalBodyMap.getRandom(this));
+    }
+
+    /**
+     * <p>
+     * returns the {@link EqualSOAPDataMap} associated with this event
+     * </p>
+     * 
+     * @return the {@link EqualSOAPDataMap}
+     */
     public EqualSOAPDataMap getEqualSOAPDataMap() {
-        return equalRequestsMap;
+        return equalBodyMap;
+    }
+
+    public CallType getCallType() {
+        return callType;
     }
 
@@ -190,5 +242,5 @@
     @Override
     public String getName() {
-        return "(" + serviceName + ", " + calledMethod + ")";
+        return "(" + callType + ":" + clientName + "->" + serviceName + ", " + calledMethod + ")";
     }
 
@@ -204,5 +256,6 @@
         }
         else if (obj instanceof SimpleSOAPEventType) {
-            return HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) &&
+            return callType.equals(((SimpleSOAPEventType) obj).callType) &&
+                HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) &&
                 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) &&
                 HTTPUtils.equals(clientName, ((SimpleSOAPEventType) obj).clientName);
@@ -220,6 +273,6 @@
     @Override
     public int hashCode() {
-        int hashCode = calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode();
-        return hashCode;
+        return callType.hashCode() + calledMethod.hashCode() + serviceName.hashCode() +
+            clientName.hashCode();
     }
 
@@ -231,5 +284,5 @@
     @Override
     public String toString() {
-        return "SimpleSOAPEventType(" + serviceName + ", " + calledMethod + ")";
+        return "SimpleSOAPEventType" + getName();
     }
 
@@ -243,19 +296,3 @@
         }
     }
-//
-//    /**
-//     * <p>
-//     * Determines how getSoapRequestBody works.
-//     * <ul>
-//     * <li>LOCALEVENT: returns the request body of the event type itself</li>
-//     * <li>RANDOM: returns a randomly draw request body for the called method using
-//     * {@link EqualSOAPDataMap#getRandom(SimpleSOAPEventType)}.
-//     * </ul>
-//     * </p>
-//     * 
-//     * @author Steffen Herbold
-//     */
-//    public static enum RequestBodyMode {
-//        LOCALEVENT, RANDOM
-//    }
 }
