cancel
Showing results for 
Search instead for 
Did you mean: 

Counting element value based on values of the other elements

New Contributor

Counting element value based on values of the other elements

Hi all,

 

I have this Soap request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:v1="http://localhost/pay/pay-ws/proc/v1" 
xmlns:type="http://localhost/pay/pay-ws/proc/v1/type">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:processRefund>
         <v1:refundRequest>
           <type:messageId>${=new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())}</type:messageId>
            <type:provider>1234</type:provider>
            <type:merchantNumber>123456789</type:merchantNumber>
            <type:paymentNumber>123456789</type:paymentNumber>
            <type:amount>107</type:amount>
            <type:signature>${new java.function.forSignature("[value from <messageId> element]|[value from <provider> element]...")}</type:signature>
         </v1:refundRequest>
      </v1:processRefund>
   </soapenv:Body>
</soapenv:Envelope>

Is it possible to read values (fixed or counted - function based) from elements and use them in function in other element (signature in this case)?

 

Thanks

5 REPLIES 5
Super Contributor

Re: Counting element value based on values of the other elements

@Mita - I couldn't understand the context. Would you like to elaborate please?

What you want to achieve here? and the use cases please.

New Contributor

Re: Counting element value based on values of the other elements

I need count value into element <signature> based on values in other elements. In element <signature> will be Java function counts signature using private key and values from others elements.

 

Final request will be something like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://gpe.cz/pay/pay-ws/proc/v1" xmlns:type="http://gpe.cz/pay/pay-ws/proc/v1/type">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:getPaymentStatus>
         <v1:paymentStatusRequest>
            <type:messageId>20190313132943615</type:messageId>
            <type:provider>1234</type:provider>
            <type:merchantNumber>9999999101</type:merchantNumber>
            <type:paymentNumber>20190221154803</type:paymentNumber>
            <type:signature>Jjydw6yw63fwiPd1fSO8Q1sKFnfEr2/JCZaAUJ/ExJCj+AgnS0bzXQ7h/5j3C5wS6MmlPU6vTXYGZy937DkZSilaDJdQgqhlN839kehgG8C8bvfRkhKeB0+JdFttHh3FX9Xo1drcvw2nvmXf2UGYvsaU0CzjldmSDac/ZoClwQFyJ4WQvTOnrsomwKP4NfjgVhb4C5gSkcPtErXFwJ2zNIpgd6zvc4u4TZ07lOnNpLqrY4o8MWE0fg+uCp4ymdXHPDyCTjTrLBrqWSsBTdZgPE9kd54siyMGpSKJ5as7NzXtAfVwFjo3Bu75fIYStg+/5yyPj8GRZiOZ6Ks0UrD+Mg==</type:signature>
         </v1:paymentStatusRequest>
      </v1:getPaymentStatus>
   </soapenv:Body>
</soapenv:Envelope>

The source for it is:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://gpe.cz/pay/pay-ws/proc/v1" xmlns:type="http://gpe.cz/pay/pay-ws/proc/v1/type">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:getPaymentStatus>
         <v1:paymentStatusRequest>
            <type:messageId>${=new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())}</type:messageId>
            <type:provider>1234</type:provider>
            <type:merchantNumber>9999999101</type:merchantNumber>
            <type:paymentNumber>20190221154803</type:paymentNumber>
            <type:signature>${new java.function.forSignature("[value from <messageId> element]|[value from <provider> element]...")}</type:signature>
         </v1:paymentStatusRequest>
      </v1:getPaymentStatus>
   </soapenv:Body>
</soapenv:Envelope>

The element <messageId> has dynamical value, based on Date. So value in <signature> element is dynamical too (based on dynamically counted value in element <messageId>).

 

My question is - if is it possible somewhere take final (dynamically counted) value from <messageId> element and use it in dynamically counted function in element <signature> in one step using button "Submit request" (as a value in element <messageId> is counted before submitting)?

 

Super Contributor

Re: Counting element value based on values of the other elements

@nmrao Any suggestions on this?

Community Hero

Re: Counting element value based on values of the other elements

Basically it would require to update the signature value at run and SoapUI Pro has feature called Events and use SubmitListenter - beforeSubmit and write code to update the value.

However, it is possible to use that feature in SoapUI Open Source edition as well if you use soapUIExtensions library and implement the same code in the respective script.

For more details, refer below thread
https://stackoverflow.com/questions/37205952/soapui-increase-property-value-for-each-test-case/37209...


Regards,
Rao.
New Contributor

Re: Counting element value based on values of the other elements

Hi thanks,

I will check it.

 

So in other words:

 

  • If I use function in element the value is counted before sending automatically - value in element <messageId> based on Date
  • If I need count value based on counted values from other elements I have to use some listener/trigger before sending - value in <signature> element

Thanks, yes that make sense :-)