0

I have a SOAP response from a TestStep in SoapUI. I want to parse each value of a specific element in the response and send it as a parameter to a separate request call to another web service.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
    <searchResponse xmlns="urn:messages_2012_2.platform.webservices.technoplat.com">
        <platformCore:searchResult xmlns:platformCore="urn:core_2012_2.platform.webservices.technoplat.com">
            <platformCore:searchRowList>
                <platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
                    <tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">
                        <platformCommon:tranId>
                            <platformCore:searchValue>17678</platformCore:searchValue>
                        </platformCommon:tranId>
                    </tranSales:basic>
                </platformCore:searchRow>
                <platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
                    <tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">                    
                        <platformCommon:tranId>
                            <platformCore:searchValue>17705</platformCore:searchValue>
                        </platformCommon:tranId>                   
                    </tranSales:basic>
                </platformCore:searchRow>
                <platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
                    <tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">
                        <platformCommon:tranId>
                            <platformCore:searchValue>17777</platformCore:searchValue>
                        </platformCommon:tranId>
                    </tranSales:basic>
                </platformCore:searchRow>          
            </platformCore:searchRowList>
        </platformCore:searchResult>
    </searchResponse>
</soapenv:Body>

In the SOAP response above, I want to capture the values: 17678, 17705 and 17777 separately and send them as a parameter to another SOAP Request TestStep. Most people recommend using a groovy script for the recursion.

My questions are: 1. whats the best way to perform extraction of values from the SOAP response above and iterate and make a separate SOAPRequest TestStep in SoapUI? 2. Assuming each value is extracted in a Groovy TestStep, how can I feed those out to a "results.txt" kind of csv (name value pair) file outside.

Any suggestions would be appreciated.

4

2 に答える 2

0

これは、私が以前に使用した方法が最善ではない可能性があります。

  1. XmlSluper による XML の解析。
    XML を処理する方法は多数あります ( http://groovy.codehaus.org/Processing+XMLを参照) 。

  2. XmlParser と CSVWriter (opencsv) を使用して XML を CSV に変換します。ここで良い例を見ました: http://blog.ktronline.com/2011/12/creating-csv-file-from-xml-using-groovy.html

于 2013-01-20T02:54:21.533 に答える
0

soapUI Pro を使用している場合、これを行う最も簡単な方法は、XML DataSource で DataSource TestStep を使用することです ( http://blog.smartbear.com/software-quality/bid/170520/How-to-Use-XML-を参照)。例としてDataSources-for-Response-Processing-in-soapUIを参照)。無料版を使用している場合は、スクリプトが最適なオプションです。

幸運を!

/オレ

于 2013-01-20T08:23:55.870 に答える