With SoapUI it's possible to send Soap XML message to a WCF service. I've the following SOAP message:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:my="http开发者_开发问答://myserviceprovider">
<soap:Header/>
<soap:Body>
<my:ProcessOrder>
<my:Orders>
<my:Order>
<my:id>randomid_1234567890</my:id>
<my:data>ABC</my:data>
</my:Order>
</my:Orders>
</my:ProcessOrder>
</soap:Body>
</soap:Envelope>
Because the WCF service expects a unique ID for my:id, I would like to know if SoapUI provides functionality to automatically generate a random GUID?
This will generate a globally unique id:
${=java.util.UUID.randomUUID()}
Rather then a random ID, I would suggest using the times stamp down to the millisecond, as the number will never be duplicated.
I haven't done this myself, but it looks like you call a string function:
01 ...
02 ...
03 <!-- text within dateEffectiveFrom tag is replaced with a date 10 days from today in yyyy-MM-dd format -->
04 <dateEffectiveFrom>${= String.format('%tF', new Date() + 10) }</dateEffectiveFrom>
05
06 <!-- TestSuite property "date" is defined as "${= String.format('%tF', new Date() + 10) }" -->
07 <!-- Another example where dynamic date is defined as TestSuite property -->
08 <!-- and then SOAP Request can refer to this TestSuite property as shown below -->
09 <dateEffectiveFrom>${#TestSuite#date}</dateEffectiveFrom>
10 ...
11 ...
http://onebyteatatime.wordpress.com/2009/04/18/soapui-tips-n-tricks-part-2/
I have just used the below code to generate random nummber in my SOAPUI request and it worked without any problem. This will generate a random number of 10 digits.
<val:Id UniqueID="${=org.apache.commons.lang.RandomStringUtils.randomNumeric(10)}"/>
If you want to change number of digits, just change the desired number of digits in randomNumeric()
method.
精彩评论