cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to setParts when using groovy to add an outgoingWss with SignatureEntry?

Highlighted
Frequent Visitor

Failed to setParts when using groovy to add an outgoingWss with SignatureEntry?

I am tring to add an outgoingWss item for authentication with certificate. The groovy code is listed below. The outgoingWss entry is created as expected except parts missed.  'Timestamp' and 'Body'  are expected in Parts.  Any idea or suggestion?

if (!WssC.getOutgoingWssByName("mycert")) {
     def owss_cert = WssC.addOutgoingWss("mycert");
     TimestampEntry timeEntry=(TimestampEntry) owss_cert.addEntry("Timestamp");
     timeEntry.setTimeToLive("500");
    timeEntry.setStrictTimestamp(true); 
    SignatureEntry signature = (SignatureEntry) owss_cert.addEntry("Signature")
    signature.setCrypto("myKeystore.jks");
    signature.setUsername("mycert");
    signature.setPassword("passwords");
    signature.setKeyIdentifierType(1);
    signature.setUseSingleCert(true);   
    List<StringToStringMap> parts = new ArrayList<StringToStringMap>();
    StringToStringMap ts = new StringToStringMap();
    ts.put("ID", "");
    ts.put("Name", "Timestamp");
    ts.put("Namespace", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
    ts.put("Encode", "Content");
    parts.add(ts);
    StringToStringMap body = new StringToStringMap();
    body.put("ID", "");
    body.put("Name", "Body");
    body.put("Namespace", "http://schemas.xmlsoap.org/soap/envelope");
    body.put("Encode", "Content");
    parts.add(body);
    signature.setParts(parts);
    signature.saveConfig(); 
}

soapUI01.PNG

Share Your Stories
Read Latest News
Top Kudoed Authors