cancel
Showing results for 
Search instead for 
Did you mean: 

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

Senior Member

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

2 REPLIES 2
Community Hero

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

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?


Regards,
Rao.
Highlighted
Community Manager

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

Hi @guoff,

 

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

---------
Tanya Gorbunova
SmartBear Community Manager

Join the September Hub-bub to show off, learn and win
New Here?
Join us and watch the welcome video:
Watch the New Interview
7Mistakes
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win