Forum Discussion

CrazyFrog's avatar
CrazyFrog
Contributor
5 years ago
Solved

add the "Outgoing WSS" information to the request from Java

Hello,

 

Who can help me (maybe someone from Smarbear Olga_T 

To add the "Outgoing WSS" to the request I use the following Java Code below, this is the same code that is used in the GUI to add the "Outgoing WSS" to the request.

The GUI use the java class "XmlSourceEditorViewFactory.java"

 

 

WsdlRequest request = ((WsdlTestRequestStep) testStep).getHttpRequest();

DefaultWssContainer wss = request.getOperation().getInterface().getProject().getWssContainer();
List<OutgoingWss> outgoingWssList = wss.getOutgoingWssList();
OutgoingWss outgoing = outgoingWssList.get(1);

ApplyOutgoingWSSToRequestAction outgoingWSSToRequestAction = new ApplyOutgoingWSSToRequestAction(request, outgoing);
outgoingWSSToRequestAction.actionPerformed(null);

 


However, when I use this code, the entire "Outgoing WSS" is not added completely while the GUI does it well.

Who can help me with this so that the complete "Outgoing WSS" is added to the request.

 

I need this so that I can then adjust the request to test the Server Side Security.

 

request renerated by the code above:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://bkwi.nl/SuwiML/Diensten/BRPDossierPersoonVraag/v0200">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
   </soapenv:Header>
   <soapenv:Body>
      <.............>
   </soapenv:Body>
</soapenv:Envelope>

Code generated by the GUI:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://bkwi.nl/SuwiML/Diensten/BRPDossierPersoonVraag/v0200">
   <soapenv:Header wsu:Id="id-2EF4DD84152C46856D156804444351038" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-2EF4DD84152C46856D156804444350935">MIIEIDCCAwgCAQMwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCTkwxEDAOBgNVBAgTB1V0cmVjaHQxEzARBgNVBAoTClNlbGZTaWduZWQxFDASBgNVBAsTC0RvY2tlckltYWdlMQswCQYDVQQDEwJDQTAeFw0xOTA1MDkxNDQ2MDFaFw0yMDA1MDgxNDQ2MDFaMFUxDjAMBgNVBAMTBUFsaWNlMR0wGwYDVQQFExQwMDAwMDAwMTIzNDU2Nzg5MDAwMDEkMCIGCgmSJomT8ixkAQETFDAwMDAwMDAxMjM0NTY3ODkwMDAwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA1h2T7s4O5nfViJuZx9C7fNMACTHjoGLCGkR+HZB3Nc1ZDCcXbxwI4NHlYsMQuA9yy0s7BRRjrDnWyKg3HPHjnFH4EhifteP9Wkqx/Urx1QRAxpZ9EbYi4fJN70IXers+2BBoJ0ziL76wiCTRK23wWkLcwTmbOfFWFPJQxbFJ6BjDoABA4wFrpM3hFmYi38J9aLDVqTyJlcpYfnQgeoik88h6swczrvBqqB/2mq0MjyvSIeXbTyKRR5aFREg/FLD7Eyt2PAQ7ZAAzQziHH+k9zwKKtD+TybixOlOra393eXFkEXMrZ6PrPEEqH5IJRePHmlq1jL/Zc4vIMVlcEIgrIyvlFQVS67VM9Z5hPfcewUxMTQCrSkI1E4Nj63Y93iGqBuyJtrT2BtnPI/jHyEgyzQd2ZVqZ1reYiRawGEHQmOwj00jVAExT7hMV9ZiZam6ZbdwoBQIexa8Ov3bGT6lAAgmsbH9GbvuKtIqNdroop0LiOuS2xbcPjmLzWIZe6uzP3ftsoKat0J+XSotqRSmlvz+Am+6Sz22KnclNgqm6Q6lDPVmcazy+H4rkSAkLpmoy3WsnBr4YvCi8h1SOBecoFVUtAsAd5ycuM1/6JxfhTYz3iZ1J3kAj0Kd2f5KHCgqC6IAZBQ843R3jw79CbISbJ/UStl3cLOgncXxnrq4MUr8CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAod6Y1gjenqxx8VplT1R19mIbp+igGX4Fajvn356DrsQc7ddHLqZ5zNlp4rC3JQS90vtY1yjaQN0mXSza8Z4VsSq+t7T4tkesoxt325839opchFFbXvvmw4BpUnk+wk8q6C7n2D2nHwbdxJJ2fcZ7Fl+wgF51+UtaWN+KU4iQx1xH1qxc9SW1nkrPHUaLXS4hiUaWR35ewj31b7D+A7Ytt2WCxIHyNBhUwHqSUs+4y8ZEAv9xTWNSeGUVTj3h1PfNglDYDdMniWO7QKHKV1eyXTdP2eIHbTUZJzIctFI9YyDZ7+7IyjK4cp7QYQiUMSSydcTyLM54WPzh/3FDkzqAgw==</wsse:BinarySecurityToken>
         <ds:Signature Id="SIG-2EF4DD84152C46856D156804444351240" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
            <ds:SignedInfo>
               <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
               <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
               <ds:Reference URI="#id-2EF4DD84152C46856D156804444351038">
                  <ds:Transforms>
                     <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <InclusiveNamespaces PrefixList="v02" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                     </ds:Transform>
                  </ds:Transforms>
                  <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                  <ds:DigestValue>956wykD/ikVCoYBcLOFxytretvcKX4xOxMqrdj50OgE=</ds:DigestValue>
               </ds:Reference>
               <ds:Reference URI="#id-2EF4DD84152C46856D156804444351039">
                  <ds:Transforms>
                     <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <InclusiveNamespaces PrefixList="v02" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                     </ds:Transform>
                  </ds:Transforms>
                  <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                  <ds:DigestValue>6M1IMxBgRwMBVXECe8+9URFG3BgM644tZnp3Ror9tpA=</ds:DigestValue>
               </ds:Reference>
            </ds:SignedInfo>
            <ds:SignatureValue>sCANEIB/nmh8CvYSLU1RqsyHlHSnruS+TYD6x0X0+TqzHvSycWEkxzX/Aim9c7Ld7Yo1R74sv7nXw091b/KQwO+8P+QL64wzIWj7JlxktIFlTJ3CndKKqKFvmOMJ5yBrB48KSrs+f4R+/55OjuHiwuG6sKUFdQmksPj7HEdXrzflX3tD7cRMEWG9oYOpIw6aiVujIcFKWzMRX9e81J4DNntCjxyqGyhoDFPr/bxryzcDA6c9cvLv0YKl5n9W/C0xmEAq4AJRVZ4oJiop1beIq1zGhvCBp7j5v3YQ3O6VG7Ustw2aIjKC2cS3UazpiONN41Y1CXduOVqhoF1nwHO64pzwpbPGmC/it5g5Yr8OOJc/vcNT13ZjpaUU2RhxHLkVDi3k9jO3xxtV/bZKUyEJCmFJ2LwxVW8ntSpfQz9Z5D6sb41TIuCIdKqTUwt4g/5N1YegypOOM4ZxmYVpSbX2LADtNQKj+C5I6odtxuddBoU5dhOL4cKerLD+xctiB1Zh/Ksi/5RzZvHMDPyglOjrKifLXgZ+e1nzSJCY3tR5oBKMgHfsk3VGh/Ev/W2akCsPEVfIGir0zEyaIj0tVm+Me2SDnfDyLDEftccWf6X/FQq9ZB8rxi0FqVdSB7o2GGyQ2oYryeOatliLyI4VnthYV2h22NGhkfgng+tU1NYn2gM=</ds:SignatureValue>
            <ds:KeyInfo Id="KI-2EF4DD84152C46856D156804444350936">
               <wsse:SecurityTokenReference wsu:Id="STR-2EF4DD84152C46856D156804444350937">
                  <wsse:Reference URI="#X509-2EF4DD84152C46856D156804444350935" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
               </wsse:SecurityTokenReference>
            </ds:KeyInfo>
         </ds:Signature>
         <wsu:Timestamp wsu:Id="TS-2EF4DD84152C46856D156804444349434">
            <wsu:Created>2019-09-09T15:54:03.494Z</wsu:Created>
            <wsu:Expires>2019-09-09T17:00:43.494Z</wsu:Expires>
         </wsu:Timestamp>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body wsu:Id="id-2EF4DD84152C46856D156804444351039" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <.........>
   </soapenv:Body>
</soapenv:Envelope>

 

 

  • CrazyFrog's avatar
    CrazyFrog
    5 years ago

    I found the problem.

     

    We generate the soapui project entirely from java and add the keystore and the

    "Outgoing WSS configurations" from java.

    To be able to use this configuration when making the test steps (from the java code)

    I first have to save the project and then read it in again.

    After re-reading it is possible to add the "Outgoing WSS" to the request from the java code.

     

    Why is the keystore and the "Outgoing WSS configuration" not immediately available

    after adding to the project (from java)?

     

    Another point, you must of course first add the "WSA-Headers" before you can properly

    add the "Outgoing WSS" to your request.

    In the example code above I had not done this yet.

     

    Current method add WsaHeaders and OutgoingWSS to a teststep.

    private static void addOutgoingWSSToRequest(WsdlTestRequestStep testStep){

    WsdlRequest request = testStep.getHttpRequest();

    DefaultWssContainer wss = request.getOperation().getInterface().getProject().getWssContainer();
    List<OutgoingWss> outgoingWssList = wss.getOutgoingWssList();
    OutgoingWss outgoing = outgoingWssList.get(0);

    AddWsaHeadersToRequestAction addWsaHeadersToRequestAction = new AddWsaHeadersToRequestAction(request);
    addWsaHeadersToRequestAction.actionPerformed(null);

    ApplyOutgoingWSSToRequestAction outgoingWSSToRequestAction = new ApplyOutgoingWSSToRequestAction(request, outgoing);
    outgoingWSSToRequestAction.actionPerformed(null);
    }

     

    Thank you for picking up the issue, but the problem is currently fixed.

    Kind regards

     

    Raymond Wiertz

    The Netherlands

3 Replies

  • Olga_T's avatar
    Olga_T
    SmartBear Alumni (Retired)

    Hi CrazyFrog

     

    Sorry for not replying sooner, let me refer to our support team, maybe they can help us here!

    • Nastya_Khovrina's avatar
      Nastya_Khovrina
      SmartBear Alumni (Retired)

      Do you get any errors in the Error log?

      Can you provide a screenshot which shows how the Outgoing WSS is configured in ReadyAPI GUI?

      • CrazyFrog's avatar
        CrazyFrog
        Contributor

        I found the problem.

         

        We generate the soapui project entirely from java and add the keystore and the

        "Outgoing WSS configurations" from java.

        To be able to use this configuration when making the test steps (from the java code)

        I first have to save the project and then read it in again.

        After re-reading it is possible to add the "Outgoing WSS" to the request from the java code.

         

        Why is the keystore and the "Outgoing WSS configuration" not immediately available

        after adding to the project (from java)?

         

        Another point, you must of course first add the "WSA-Headers" before you can properly

        add the "Outgoing WSS" to your request.

        In the example code above I had not done this yet.

         

        Current method add WsaHeaders and OutgoingWSS to a teststep.

        private static void addOutgoingWSSToRequest(WsdlTestRequestStep testStep){

        WsdlRequest request = testStep.getHttpRequest();

        DefaultWssContainer wss = request.getOperation().getInterface().getProject().getWssContainer();
        List<OutgoingWss> outgoingWssList = wss.getOutgoingWssList();
        OutgoingWss outgoing = outgoingWssList.get(0);

        AddWsaHeadersToRequestAction addWsaHeadersToRequestAction = new AddWsaHeadersToRequestAction(request);
        addWsaHeadersToRequestAction.actionPerformed(null);

        ApplyOutgoingWSSToRequestAction outgoingWSSToRequestAction = new ApplyOutgoingWSSToRequestAction(request, outgoing);
        outgoingWSSToRequestAction.actionPerformed(null);
        }

         

        Thank you for picking up the issue, but the problem is currently fixed.

        Kind regards

         

        Raymond Wiertz

        The Netherlands