Forum Discussion

guoff's avatar
guoff
Senior Member
6 years ago

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(); 
}

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Where does the above script lying? how it gets executed?

    If you are using for sending SOAP request, than can't SOAP Request step be used which automatically being taken care by the tool?
    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Hi guoff,

       

      Was the answer to your question found? Please share your solution with us.