我的XML请求看起来像这样:
<ns:complete>
<ns:identifier>23265</ns:identifier>
<ns:taskData><![CDATA[<sch:SubscriptionApprovalResponse xmlns:sch="http://workflow.subscription.apimgt.carbon.wso2.org">
<sch:status>APPROVED</sch:status>
<sch:workflowExternalRef>#(ref)</sch:workflowExternalRef>
<sch:description></sch:description>
</sch:SubscriptionApprovalResponse>]]></ns:taskData>
</ns:complete>
我在CDATA体内从外面传递#(ref),但它没有读它。
我做错了吗?
是的,因为您正在尝试在CDATA
部分中使用嵌入式表达式。没有一个完整的工作例子,我不能说。
您应该分两步执行此操作或使用字符串replace
:https://github.com/intuit/karate#replace
* def baz = 'blah'
* def foo = <bar>#(baz)</bar>
* def xml = <foo><Response><![CDATA[#(foo)]]></Response></foo>
* match xml == <foo><Response><![CDATA[<bar>blah</bar>]]></Response></foo>
* def xml = <foo><Response><![CDATA[<bar>@@baz@@</bar>]]></Response></foo>
* replace xml.@@baz@@ = 'blah'
* match xml == <foo><Response><![CDATA[<bar>blah</bar>]]></Response></foo>