Ignore:
Timestamp:
03/18/15 09:58:50 (9 years ago)
Author:
sherbold
Message:
  • SimpleSOAPEvent now contains body of the SOAP request
  • SOAPUtils created
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java

    r1913 r1924  
    1515package de.ugoe.cs.autoquest.plugin.http.eventcore; 
    1616 
     17import java.io.ByteArrayInputStream; 
     18import java.io.IOException; 
     19 
     20import javax.xml.parsers.DocumentBuilderFactory; 
     21import javax.xml.parsers.ParserConfigurationException; 
     22 
     23import org.w3c.dom.Element; 
     24import org.xml.sax.SAXException; 
     25 
    1726import de.ugoe.cs.autoquest.eventcore.IEventType; 
    1827import de.ugoe.cs.autoquest.plugin.http.HTTPUtils; 
     28import de.ugoe.cs.autoquest.plugin.http.SOAPUtils; 
    1929 
    2030/** 
     
    4454     */ 
    4555    private final String serviceName; 
    46      
     56 
    4757    /** 
    4858     * <p> 
    49      * the name of the client; this is either the host/ip and port of the sender or, if a path 
    50      * map is available, a human readable name that may be based also on the receiver 
     59     * the name of the client; this is either the host/ip and port of the sender or, if a path map 
     60     * is available, a human readable name that may be based also on the receiver 
    5161     * </p> 
    5262     */ 
    5363    private final String clientName; 
     64 
     65    /** 
     66     * <p> 
     67     * the body of the SOAP request; storage as serialized XML string to allow object serialization 
     68     * </p> 
     69     */ 
     70    private final String soapRequestBody; 
    5471 
    5572    /** 
     
    5976     *  
    6077     */ 
    61     public SimpleSOAPEventType(String calledMethod, String serviceName, String clientName) { 
     78    public SimpleSOAPEventType(String calledMethod, 
     79                               String serviceName, 
     80                               String clientName, 
     81                               Element soapRequestBody) 
     82    { 
    6283        if (calledMethod == null) { 
    6384            throw new IllegalArgumentException("called method must not be null"); 
     
    6990            throw new IllegalArgumentException("clientName must not be null"); 
    7091        } 
     92        if (soapRequestBody == null) { 
     93            throw new IllegalArgumentException("soapRequestBody must not be null"); 
     94        } 
    7195        this.calledMethod = calledMethod; 
    7296        this.serviceName = serviceName; 
    7397        this.clientName = clientName; 
     98        this.soapRequestBody = SOAPUtils.getSerialization(soapRequestBody); 
    7499    } 
    75100 
     
    95120        return serviceName; 
    96121    } 
    97      
     122 
    98123    /** 
    99124     * <p> 
    100125     * the name of the client calling in this request 
    101126     * </p> 
    102      * 
     127     *  
    103128     * @return the name of the client calling in this request 
    104129     */ 
    105130    public String getClientName() { 
    106131        return clientName; 
     132    } 
     133 
     134    public Element getSoapRequestBody() { 
     135        try { 
     136            return DocumentBuilderFactory.newInstance().newDocumentBuilder() 
     137                .parse(new ByteArrayInputStream(soapRequestBody.getBytes())).getDocumentElement(); 
     138        } 
     139        catch (SAXException | IOException | ParserConfigurationException e) { 
     140            return null; 
     141        } 
    107142    } 
    108143 
     
    129164        else if (obj instanceof SimpleSOAPEventType) { 
    130165            return HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 
    131                 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName); 
     166                HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) && 
     167                HTTPUtils.equals(clientName, ((SimpleSOAPEventType) obj).clientName); 
    132168        } 
    133169        else { 
     
    143179    @Override 
    144180    public int hashCode() { 
    145         int hashCode = calledMethod.hashCode() + serviceName.hashCode(); 
     181        int hashCode = calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode(); 
    146182        return hashCode; 
    147183    } 
    148      
    149     /* (non-Javadoc) 
     184 
     185    /* 
     186     * (non-Javadoc) 
     187     *  
    150188     * @see java.lang.Object#toString() 
    151189     */ 
Note: See TracChangeset for help on using the changeset viewer.