2
以下のWebサービスリクエストがあります。私はgroovyスクリプトを使用してプロパティを更新しようとしています。soapui xmlタグ値の更新(groovyスクリプトを使用)
Webサービス:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webserviceX.NET/">
<soap:Header/>
<soap:Body>
<web:ChangeLengthUnit>
<web:LengthValue>${=(int)(Math.random()*9999)}</web:LengthValue>
<web:fromLengthUnit>Inches</web:fromLengthUnit>
<web:toLengthUnit>Centimeters</web:toLengthUnit>
</web:ChangeLengthUnit>
</soap:Body>
</soap:Envelope>
のGroovyスクリプト:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
// get XmlHolder for request message def
holder = groovyUtils.getXmlHolder("ChangeLengthUnit#RawRequest")
// change password using XPath
holder["//*:LengthValue"] = "1234"
// write updated request back to teststep
holder.updateProperty()
context.requestContent = holder.xml
は、私は上記のスクリプトを使用してLengthvalueタグを更新することができません。私はあなたが
が言うことができます簡単な方法でそれを行うことができると思うエラー
org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA error at line: 4
は今、あなたは簡単に次の要求でその値を使用することができます。なぜもう一度更新したいのですか? – Rao
@Rao、リクエストXMLにいくつかの特殊文字が渡されています。上記の例は私の問題と似ています。私は実際のプロジェクトでランダムな値を使用していません。 –
要求を更新する値は何ですか?毎回静的な値または動的な値?あなたは無料のバージョンまたはプロを使用していますか? – Rao